So I am looking WPF – Windows Presentation Foundation – Microsoft’s latest GUI framework. As a .NET developer, having worked on web forms and WinForms, I am curious as to what WPF framework offers, as unlike WinForms which was built on top of Windows Controls, WPF was built from scratch.
WPF allows the look and behavior of controls to be customized by using templates and resources.
Databinding allows good separation between data and UI. Of course that also means a bit more coding. WPF in concert with MVVM (Model-View-ViewModel), gives us the ability to write code that is easy to maintain and extend. MVVM is a design pattern, where M- Model is the model of your data, the V-View is the presentation of your data, and the code behind in the VM-View Model that connects the model to the view and abstracts data from the view, and properties of a View are bound to the ViewModel, which keeps the View updated. Unit Testing is a lot easier with ViewModels. MVVM was introduced in 2005.
The tooling support in Visual Studio is still limited and will probably improve in future versions. WPF application requires the .NET framework to run, which is delivered with Windows. The WPF UI code is XAML and the code behind is C# or any other .NET language. XAML, which stands for eXtensible Application Markup Language, is Microsoft’s variant of XML for describing a GUI. An example of what the XAML looks like for a window that shows a green button that says select.
“
Of course a very simple example.