presence_new/Presence.Desktop/App.axaml.cs

37 lines
1.1 KiB
C#
Raw Permalink Normal View History

2024-12-05 06:55:28 +00:00
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
2024-12-13 07:21:14 +00:00
using Microsoft.Extensions.DependencyInjection;
using Presence.Desktop.DI;
2024-12-05 06:55:28 +00:00
using Presence.Desktop.ViewModels;
using Presence.Desktop.Views;
2024-12-13 07:21:14 +00:00
namespace Presence.Desktop
2024-12-05 06:55:28 +00:00
{
2024-12-13 07:21:14 +00:00
public partial class App : Application
2024-12-05 06:55:28 +00:00
{
2024-12-13 07:21:14 +00:00
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
2024-12-05 06:55:28 +00:00
2024-12-13 07:21:14 +00:00
public override void OnFrameworkInitializationCompleted()
2024-12-05 06:55:28 +00:00
{
2024-12-13 07:21:14 +00:00
var serviceCollection = new ServiceCollection();
serviceCollection.AddCommonService();
var services = serviceCollection.BuildServiceProvider();
var mainViewModel = services.GetRequiredService<GroupViewModel>();
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
2024-12-05 06:55:28 +00:00
{
2024-12-13 07:21:14 +00:00
desktop.MainWindow = new MainWindow()
{
DataContext = new MainWindowViewModel(services),
};
}
base.OnFrameworkInitializationCompleted();
2024-12-05 06:55:28 +00:00
}
}
}