-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBootstrapper.cs
55 lines (46 loc) · 1.88 KB
/
Bootstrapper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using Microsoft.Practices.Unity;
using Prism.Regions;
using Prism.Unity;
using PrismWindowNavExample.Navigation;
using PrismWindowNavExample.Views;
using System.Threading;
using System.Windows;
namespace PrismWindowNavExample
{
public class Bootstrapper : UnityBootstrapper
{
protected override void ConfigureContainer()
{
base.ConfigureContainer();
Container.RegisterType<IWindowNavigationService, WindowNavigationService>(new ContainerControlledLifetimeManager());
Container.RegisterType<IWindowPersistanceService, WindowPersistenceStore>();
Container.RegisterType<IWindowManager, WindowManager>();
}
protected override IRegionBehaviorFactory ConfigureDefaultRegionBehaviors()
{
var behaviors = base.ConfigureDefaultRegionBehaviors();
behaviors.AddIfMissing(RegionManagerAwareBehavior.BehaviorKey, typeof(RegionManagerAwareBehavior));
behaviors.AddIfMissing(WindowManagerAwareBehavior.BehaviorKey, typeof(WindowManagerAwareBehavior));
return behaviors;
}
protected override DependencyObject CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void InitializeModules()
{
base.InitializeModules();
Container.RegisterTypeForNavigation<ChildView>();
}
protected override void InitializeShell()
{
WindowManagerAware.SetWindowManager(Shell, Container.Resolve<IWindowManager>());
var regionManager = Container.Resolve<IRegionManager>();
Application.Current.MainWindow.Show();
SynchronizationContext.Current.Post((state) =>
{
regionManager.RequestNavigate("WindowContentRegion", nameof(ChildView), new NavigationParameters());
}, null);
}
}
}