Sample01 1.0.0.0
Sample01 사용 방법을 보여 주는 예제 프로젝트입니다.
로딩중...
검색중...
일치하는것 없음
App.xaml.cs
이 파일의 문서화 페이지로 가기
1using Dreamine.Hybrid.Wpf.Interfaces;
7using Microsoft.Extensions.DependencyInjection;
10using System;
11using System.Windows;
12namespace Sample01
13{
22 public partial class App : Application, IDreamineServiceProviderAware
23 {
32 public static IServiceProvider? ServiceProvider { get; private set; }
33
58 public void SetServiceProvider(IServiceProvider serviceProvider)
59 {
60 ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
61 }
62
87 protected override void OnStartup(StartupEventArgs e)
88 {
89 base.OnStartup(e);
90
91 if (ServiceProvider is null)
92 throw new InvalidOperationException("ServiceProvider 초기화 실패: Program.BuildHost가 먼저 호출되어야 합니다.");
93
94 var vm = ServiceProvider.GetRequiredService<MainWindowViewModel>();
95 var win = ServiceProvider.GetRequiredService<MainWindow>();
96 win.DataContext = vm;
97
98 MainWindow = win;
99 win.Show();
100 }
101 }
102}
override void OnStartup(StartupEventArgs e)
Definition App.xaml.cs:87
void SetServiceProvider(IServiceProvider serviceProvider)
Definition App.xaml.cs:58
static ? IServiceProvider ServiceProvider
Definition App.xaml.cs:32