I am starting a multi part series on creating your first Prism WPF project.
First download Prism 5 which is the latest release version. http://www.microsoft.com/en-us/download/details.aspx?id=42537
We will be starting with the project located in the path:
[C:\projects]\Prism 5\Quickstarts\Hello World\HelloWorld.Desktop (where C:\projects is your file extraction location)
Your solution should look like this:
There are two projects, HelloWorld.Desktop and HelloWorldModule. HelloWorld.Desktop contains the bootstrapper and shell and is refered to as the shell project. HelloWorldModule contains the form we will be loading.
Prism enables different modules to separate concerns. These are great for working with teams and organization. Other modules normally created are an infrastructure module, for containing common classes and interfaces, a service module for data access classes, and many more modules for groups of forms. Examples for form groups are graphs, reports, and data entry forms.
Let us review each file for its importance and use. I am going in order of code execution. The first file is App.xaml. This file in a regular WPF application would call MainWindow.xaml. In this case, it has been repurposed to call the Bootstrapper class from the OnStartup event. The OnStartup event executes when the program is launched.
The next file inherits from UnityBootstrapper which is part of the Prism framework. It is open source, to see its functionality navigate to GitHub. https://github.com/PrismLibrary/Prism/blob/master/Source/Wpf/Prism.Unity.Wpf/UnityBootstrapper.cs
Review the Run method. In it you will see it call ConfigureModuleCatalog(), CreateShell(), and InitializeShell(). Those are the overriden methods we use in our project.
Back into our HelloWorld.Desktop project, reviewing Bootstrapper.cs, we override the methods in order to register our modules, data types, and the shell.
We create a ModuleCatalog object which is part of Prism. We call its AddModule method. We do this for all of our modules.
In the CreateShell method we assign the shell class.
In the InitializeShell method we show the shell, which is our main window of this program.
We will learn about setting up the shell and regions in the next chapter.