-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.axaml.cs
51 lines (44 loc) · 1.75 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using Tessera.Services;
using Microsoft.Extensions.DependencyInjection;
using Tessera.ViewModels;
using Tessera.Views;
using System;
using Avalonia.Controls.Shapes;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Tessera
{
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
var services = new ServiceCollection();
services.AddSingleton<IFilesService>(x => new FilesService(desktop.MainWindow));
services.AddSingleton<IFileEntityRelationsService>(x => new FileEntityRelationsService());
Services = services.BuildServiceProvider();
// Line below is needed to remove Avalonia data validation.
// Without this line you will get duplicate validations from both Avalonia and CT
BindingPlugins.DataValidators.RemoveAt(0);
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
}
base.OnFrameworkInitializationCompleted();
}
public new static App? Current => Application.Current as App;
/// <summary>
/// Gets the <see cref="IServiceProvider"/> instance to resolve application services.
/// </summary>
public IServiceProvider? Services { get; private set; }
}
}