Sharing the .NET 5 library with a WPF application
Class libraries are a great way to share code across multiple projects. It's also one way you can incrementally migrate applications to a new UI platform like WinUI. If you have your ViewModels or other business logic in separate .NET assemblies (or web services), the effort needed to build a new and modern UI is greatly reduced. If your existing desktop apps are single assembly monoliths, refactoring business logic into a separate class library is a great first step in a migration effort.
By defining our ViewModel in a separate .NET class library project, we can easily consume it in multiple UI projects. This separation also helps to ensure that the ViewModels will not have any dependencies on WinUI or other UI frameworks. Let's create a WPF project that also uses a WebView2 control:
- Start by making sure you have the required version of Microsoft Edge installed. At the time of this writing, the Dev or Canary channel...