Referencing .NET 5 Libraries from your project
A WinUI desktop project is a .NET 5 project, so it's easy to reference any other .NET 5 project, NuGet package, or local DLL. We want to update our WebViewBrowser project to use MVVM but using MVVM doesn't require the views and ViewModel classes to be in the same project. It's possible to share ViewModels across multiple projects if they are created in their own .NET assembly.
We are going to add a .NET library to the WebViewBrowser solution to hold a ViewModel
class for the MainWindow:
- Start by right-clicking the solution file in Solution Explorer and select Add | New Project.
- On the Add a new project window, select C# from the Language dropdown and Library from the Project Types dropdown to filter the list of templates. Find and select the Class Library (.NET Core) template and click Next.
Note
A .NET Standard library project can also be created for sharing code across multiple projects. The advantage of using...