What is WPF?

Facebook
Twitter
LinkedIn

Never miss a post!

Sign up for our newsletter and get FREE Development Trends delivered directly to your inbox.

You can unsubscribe any time. Terms & Conditions.
Categories

In this blog, we will take a look at WPF (Windows Presentation Foundation). What it is, how it has evolved over the years and what is in the future of WPF.

What is WPF?

WPF stands for Windows Presentation Foundation. It is a UI framework for developing Windows desktop applications. WPF makes use of Extensible Application Markup Language, better referred to as XAML to define views in a declarative manner. It contains highly rich UI features and built-in support for resources, graphics, data binding and event triggers.

WPF was introduced in 2006 as part of the .NET Framework 3.0. Upon writing this, WPF has been part of the .NET Framework for 14 years. As of lately, it has also been added to .NET Core.

Moreover, the same day that .NET Core 3.0 Preview was announced, Microsoft made the announcement that WPF had become open source. This meant that the community could contribute features and bug fixes to the framework. Being open-source along with being part of .NET Core, proves WPF is here to stay.

WPF in .NET Core

Microsoft released .NET Core 3.0 this year. .NET Core 3 introduces support for WPF apps and Windows Forms. At its Build 2019 conference, Microsoft gave its .NET roadmap. One of its main goals was to incorporate .NET framework service fixes into the new .NET Core.

Developers using WPF can now take advantage of .NET Core platform features such as deploying options and improving runtime performance for API classes like I/O and networking. WPF in .NET Core also means you can make use of Windows 10 capabilities more such as MSIX packaging technology, Nuget platform APIs and UI updates via XAML islands. We will talk about XAML islands a little further on.

One drawback is that since WPF uses a lot of Windows-specific features, WPF in .NET Core will still only run on Windows. .NET Core is most known for its cross-platform framework abilities, so it’s a little surprising. However, given the historical intension for WPF use, its to be expected.

Migrating WPF to .NET Core

Although it’s not required to migrate WPF to .NET Core, it is recommended by Microsoft. Microsoft recommends that new projects should be built using the new .NET Core platform but legacy apps that are not under maintenance or not business-critical can stay in .NET Framework. Microsoft indicates that the .NET Framework will be available for a considerably extended time.

Here are the steps to follow to migrate your WPF project in .NET Framework to .NET Core:

  1. Firstly, you need to understand the project’s dependencies. Using tools like .NET Portability Analyzer will help in analyzing the .NET framework dependencies and preparing the project into a simple portable state.
  2. Secondly, you need to update any NuGet references and use <PackageReference> format instead. Also, you may need to check if any of your NuGet package references need updating.
  3. Update your csproj profile file. You can either alter the one you have or create a new project file.
  4. Next step is to look at the source code. It may need to be updated using the latest API based in .NET Core or in .NET core versions that use Nuget Packages.
  5. The last step is to test the migrated app. Roslyn code analyzers may help to identify run-time potential errors.

For more detailed information and step-by-step procedure, take a look at Microsoft’s dev blog.

Future of WPF

In Microsoft Ignite 2020, we got the first preview of XAML islands and WinUI 3 for Windows desktop applications.

XAML islands are a set of built-in controls based on XAML that you can drag and drop from the Windows Community Toolkit. However, if you have something custom or you built a UWP application and you want to incorporate it inside your WPF application, you just use a XAML host. For more details on how to achieve this, see here.

WinUI 3 is still in the alpha phase but it is available to test out. Currently, WinUI is a UX framework for Windows desktop and UWP apps. In the future, they foresee it as becoming a large UI framework that mixes UI technologies from WinForms, UWP and WPF as a central framework.

Facebook
Twitter
LinkedIn

Our website uses cookies that help it to function, allow us to analyze how you interact with it, and help us to improve its performance. By using our website you agree by our Terms and Conditions and Privacy Policy.