WPF is an abbreviation of Windows Presentation Foundation which let us create desktop applications on windows platform.
Advantages of WPF over Winforms: -
- Single code for web and windows – When it comes to WPF using the same code which wrote for desktop application we can create application which will execute in browser. WPF uses XAML for representing the UI structure which is going to same for WPF application and WPF Browser application.
- Binding–Strong Binding feature in WPF make it follow MVVM pattern easily and thus makes UI less cluttered and move our presentation logic to VM and thus makes unit testing easier.
- Common look and feel – With the introduction of styles in windows programming WPF brought up “web css” in desktop world. Create one style and reuse it acorss multiple controls across multiple forms.
- Declarative programming– We can do many thing without writing a single line of code. We just have to set couple of things in XAML design and we will get what we are expecting.
- Expression blend – Creating animation is easy now with the help of expression blend tool which is a part of Visual studio
- Faster execution – Performance of WPF application will be more than WinForms. It seems strange but it’s true. WPF internally uses Direct X whereas windows uses GDI and User32. Now DirectX has the capability to do hardware rendering whereas GDI does only software rendering.
Software rendering mean CPU is responsible for where Hardware rendering means GPU is responsible for rendering. In case of WPF CPU will be loaded less because rendering will be handled by GPU.
- Resolution indecency– WPF uses DIP – Device independent pixels for displaying elements in the windows.
Below video explain what is WPF and how they differ from Windows form