Prism is an open source framework for building loosely coupled, maintainable and testable XAML applications in WPF and Xamarin Forms.
Method 1: Create manually
Create a .Net Framework or .Net Core WPF project. Note that the latest 8.0 only supports .Net Framework 4.6.2 and above.
Prism supports two dependency injection containers, DryIOC and Unity, by default. Here we use Unity directly and search in the NuGet package manager Prism.Unity
.
Modify App.xaml
as follows, use PrismApplication
rewrite method:
public partial class App
{
protected override Window CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
}
}
Method 2: Create using templates
Search for Prism Template in the VS extension management and install the following extension.
After the installation is complete, restart VS. When creating a new project, you can directly choose to use the Prism template to create it.
Just select the container you want to use when creating it.