-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
62 lines (52 loc) · 2.01 KB
/
Program.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
56
57
58
59
60
61
62
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Markup;
using Microsoft.UI.Xaml.XamlTypeInfo;
namespace CSharp_WinUI3_DesktopWindowXamlSource
{
internal class Program : Microsoft.UI.Xaml.Application, IXamlMetadataProvider
{
private static XamlControlsXamlMetaDataProvider? xamlMetaDataProvider = null;
public Program()
{
System.Windows.Forms.Application.Run(new Form1());
}
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
XamlControlsXamlMetaDataProvider.Initialize();
xamlMetaDataProvider = new();
this.Resources.MergedDictionaries.Add(new Microsoft.UI.Xaml.Controls.XamlControlsResources());
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Microsoft.UI.Xaml.Application.Start((p) =>
{
var syncContext = new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread());
SynchronizationContext.SetSynchronizationContext(syncContext);
new Program();
var currentApp = Microsoft.UI.Xaml.Application.Current;
if (currentApp is not null)
currentApp.Exit();
});
}
public IXamlType GetXamlType(Type type)
{
return xamlMetaDataProvider.GetXamlType(type);
}
public IXamlType GetXamlType(string fullName)
{
return xamlMetaDataProvider.GetXamlType(fullName);
}
public XmlnsDefinition[] GetXmlnsDefinitions()
{
return xamlMetaDataProvider.GetXmlnsDefinitions();
}
}
}