Dreamine.Hybrid.Wpf 1.0.3
`AddDreamineHybridWpf()` 내부에서 `AddWpfBlazorWebView()` 호출 및
로딩중...
검색중...
일치하는것 없음
HybridHostControl.xaml.cs
이 파일의 문서화 페이지로 가기
1// \file HybridHostControl.xaml.cs
2// WPF에서 BlazorWebView를 Embedded 형태로 호스팅하는 컨트롤.
3// \author Dreamine
4// \date 2026-01-28
5// \version 1.0.0
6using Microsoft.AspNetCore.Components.WebView.Wpf;
7using System;
8using System.ComponentModel;
9using System.Windows;
10using System.Windows.Controls;
12{
21 public partial class HybridHostControl : UserControl
22 {
31 private bool _isInitialized;
32
41 public string HostPage { get; set; } = "wwwroot/index.html";
42
51 public Type? RootComponentType { get; set; }
52
61 public string RootSelector { get; set; } = "#app";
62
71 public IServiceProvider? Services { get; set; }
72
82 {
83 InitializeComponent();
84 if (DesignerProperties.GetIsInDesignMode(this)) return;
85 Loaded += OnLoaded;
86 }
87
120 private void OnLoaded(object sender, RoutedEventArgs e)
121 {
122 if (_isInitialized) return;
123 _isInitialized = true;
124
125 if (RootComponentType == null) throw new InvalidOperationException("RootComponentType must be set.");
126 if (Services == null) throw new InvalidOperationException("Services must be set.");
127
128 BlazorView.HostPage = HostPage;
129 BlazorView.Services = Services;
130
131 BlazorView.RootComponents.Clear();
132 BlazorView.RootComponents.Add(new RootComponent
133 {
134 Selector = RootSelector,
135 ComponentType = RootComponentType
136 });
137 }
138 }
139}
void OnLoaded(object sender, RoutedEventArgs e)