Windows Presentation Foundation

Windows Presentation Foundation

What is Windows Presentation Foundation?

Windows Presentation Foundation or WPF, codenamed Avalon during development, is the user-interface framework from Microsoft that is resolution independent and uses a vector-based rendering engine that takes advantage of modern graphics hardware. Controls can be defined either in C# code or with XAML or eXtensible Application Markup Language supporting controls that can have styles and templates along with databinding, layouts, 2D graphics, animations, media, and text with typography. Windows Presentation Foundation allows developers to build a WPF Applications natively on Windows by installing the .NET desktop development workload for Visual Studio. Developers can drag-and-drop controls to create the user interface of their applications in the Design View or write markup directly in the XAML View.

There are two implementations of Windows Presentation Foundation the first implementation is the legacy .NET Framework 4 version, with WPF being first introduced with .NET Framework 3. Applications based on WPF using .NET Framework such as part of Visual Studio 2022 but only applications targeting Windows although WPF applications can take advantage of any functionality of the legacy .NET Framework. The second implementation is open source on GitHub and runs on the latest version of modern .NET although any applications using WPF will also only run on Windows, however WPF applications can take advantage of all the features of modern .NET including Blazor with Blazor Hybrid or even ASP.NET Core Web App and ASP.NET Core Web API features.

Why should you use Windows Presentation Foundation?

Windows Presentation Foundation enables developers to create applications with markup with XAML or eXtensible Application Markup Language to implement the appearance of an application while using other code such as C# to implement the behaviour of an application. Separating the user interface from implementation including such as events, business objects and other code means it is not tightly coupled to this implementation. This allows designers to implement their own look-and-feel for controls and developers can depend on the behaviour of controls to remain the same regardless of how the controls look. Internationalisation and localisation of applications can be made easier by using resources to define text or graphics to be used or even support language features such as right-to-left more easily. Interaction between the front-end XAML and back-end implementation can be facilitated using databinding, allowing values to be displayed to users as needed, or input from users where needed.

Developers who target Windows Presentation Foundation can not only take advantage separation of appearance from behaviour in their applications but can also leverage examples of XAML using legacy WPF with .NET Framework to bring back or modernise old user interfaces for modern .NET and WPF or take advantage of a vast ecosystem of controls and toolkits available for use with Windows Presentation Foundation and modern .NET. Targeting a wider range of versions of Windows from Windows 7 to Windows 11 gives the widest range of targets for developing Windows applications using XAML.

Where can you learn more about Windows Presentation Foundation?

You can check out documentation on Microsoft Learn - Windows Presentation Foundation or you can check out GitHub - Windows Presentation Foundation (WPF). You can also check out the Talk on Windows Presentation Foundation with .NET, which goes over Windows Presentation Foundation with modern .NET along with XAML and leverage other parts of the modern .NET ecosystem such as Blazor along with a Demo you can download and try out yourself from GitHub.