For this post I will be using the following:
- Windows 10 Pro, Version 1709, Build 16299.248
- Visual Studio Enterprise 2017, Version 15.5.7
- .NET Framework 4.7.02556
- Prism 126.96.36.1996
When creating WPF applications Prism is a great way to build loosely coupled, maintainable and testable applications. However, the documentation is focused on version 6.3. If you are curious of how to use the latest version (188.8.131.526 as of this writing) you have to figure out how to initialize your application. This post shows you how to get a new project loading the shell.
Start by creating a new WPF application.
Next we are going to add Prism to our project. Right-click on the project in solution explorer and select Manage NuGet Packages…
From the Browse tab make sure Include prelease is checked and search for “Prism.Wpf”.
Now repeat the search for “Prism.Unity” and install it.
Clear the search box, click the Updates tab and install any updates.
Previous versions of Prism used a bootstrapper class. However, 7.0 added a new application base class to use instead.
Open App.xaml and replace the StartupUri attribute with:
Now add “prism:Prism” to all the Application elements.
Open App.xaml.cs and change the base class from Application to PrismApplication. Then use the light blub to add the using statements.
Finally copy and paste the code below into your class and use the light blub to add any using statements.
protected override void RegisterTypes(IContainerRegistry containerRegistry)
protected override Window CreateShell()
Now you can press F5 to run your Prism 7.0 application.