[C#/WPF/PRISM] UnityBootstrapper 클래스 : 기본 부트스트래퍼와 쉘 생성하기
■ UnityBootstrapper 클래스를 사용해 기본 부트스트래퍼와 쉘을 생성하는 방법을 보여준다. ▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 |
<Window x:Class="TestProject.Views.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="800" Height="600" Title="UnityBootstrapper 클래스 : 기본 부트스트래퍼와 쉘 생성하기"> <Grid> <ContentControl /> </Grid> </Window> |
▶ MainWindow.xaml.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 |
using System.Windows; namespace TestProject.Views { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); } #endregion } } |
▶ 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 |
using System.Windows; using Unity; using Prism.Unity; using TestProject.Views; namespace TestProject { /// <summary> /// 부트스트래퍼 /// </summary> public class Bootstrapper : UnityBootstrapper { //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Protected #region 쉘 생성하기 - CreateShell() /// <summary> /// 쉘 생성하기 /// </summary> /// <returns>쉘</returns> protected override DependencyObject CreateShell() { return Container.Resolve<MainWindow>(); } #endregion #region 쉘 초기화하기 - InitializeShell() /// <summary> /// 쉘 초기화하기 /// </summary> protected override void InitializeShell() { Application.Current.MainWindow.Show(); } #endregion } } |
▶ MainApplication.xaml
1 2 3 4 5 6 |
<Application x:Class="TestProject.MainApplication" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> </Application> |