-
Notifications
You must be signed in to change notification settings - Fork 22
/
App.axaml.cs
36 lines (30 loc) · 1.11 KB
/
App.axaml.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
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
namespace AvaloniaApp;
public class App : Application
{
public override void Initialize() => AvaloniaXamlLoader.Load(this);
public override void OnFrameworkInitializationCompleted()
{
if (Resources[nameof(Composition)] is Composition composition)
{
// Assigns the main window/view
switch (ApplicationLifetime)
{
case IClassicDesktopStyleApplicationLifetime desktop:
desktop.MainWindow = composition.MainWindow;
break;
case ISingleViewApplicationLifetime singleViewPlatform:
singleViewPlatform.MainView = composition.MainWindow;
break;
}
// Handles disposables
if (ApplicationLifetime is IControlledApplicationLifetime controlledApplicationLifetime)
{
controlledApplicationLifetime.Exit += (_, _) => composition.Dispose();
}
}
base.OnFrameworkInitializationCompleted();
}
}