Here is a step by step description on how I set up the project:
1. Shell app
Create a Wpf Application
1.1 Install Prism using NuGet
1.1.1 Install Extensions using NuGet
Do the same for the extension to be used to load modules:
Install-Package Prism.UnityExtensions
Install-Package Prism.UnityExtensions
Or
1.2 Rename MainWindow
1.3 Add region in Shell.xaml
1.4 Add Bootstrapper
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.UnityExtensions;
using Microsoft.Practices.Unity;
The bootstrapper should inherit from the UnitBootstrapper if it is the Unity extension you are using:
: UnityBootstrapper
Override methods as shown below:
protected override DependencyObject CreateShell()
{
return new Shell();
}
protected override void InitializeShell()
{
base.InitializeShell();
App.Current.MainWindow = (Window)this.Shell;
App.Current.MainWindow.Show();
}
protected override void ConfigureModuleCatalog()
{
base.ConfigureModuleCatalog();
}
1.5 App.cs
Change the App.cs so that the Bootstrapper gets called:
protected override void OnStartup(StartupEventArgs e) {
base.OnStartup(e);
Bootstrapper bootstrapper = new Bootstrapper();
bootstrapper.Run();
Bootstrapper bootstrapper = new Bootstrapper();
bootstrapper.Run();
}
1.6 App.xaml
The bootstrapper is now doing the job remove StartupUri in App.xaml:
StartupUri="MainWindow.xaml"
2. Module
Install-Package prism
2.1.1 Extensions
Install-Package Prism.UnityExtensions
Or
Install-Package Prism.MefExtensions
PresentationCore.dll
PresentationFramework.dll
WindowsBase.dll
System.Xaml.dll
Class1 to Map
2.4 Add code to MapModule
Add using:
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Modularity;
Let MapModule inherit IModule:
: IModule
public void Initialize()
{
}
2.4.1 Solutions folders
Add Solution folders:
- Model
- Services. In this folder, you store service implementations and service interfaces.
- ViewModels. In this folder, you store view models.
- Views. In this folder you add your views.
2.5 Connect the Module with Shell
2.5.1 Add reference
In Shell project add areference to the Module project
2.5.2 Change code in Bootstrapper
3. Add View
3.1 Add xaml
Before we can add our map we need to add some references to the ArcGIS for WPF:
Add some esri elements to the view so we can see if it get's loaded correctly:
When running the application the end result looks like this:
No comments:
Post a Comment