diff --git a/App.xaml.cs b/App.xaml.cs index 46d1a1a..8e74d48 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -8,21 +8,26 @@ public partial class App : Application public App() { InitializeComponent(); - - var services = new ServiceCollection(); - ConfigureServices(services); - var serviceProvider = services.BuildServiceProvider(); - - MainPage = serviceProvider.GetService(); } - private void ConfigureServices(ServiceCollection services) + protected override Window CreateWindow(IActivationState? activationState) { - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); + // Создаем сервисы непосредственно в CreateWindow + var fileService = new FileSystemService(); + var panelManager = new PanelManager(); + var fileOperations = new FileOperations(); + var keyboardService = new KeyboardService(); + var pathHelper = new PathHelper(); + + var mainPage = new MainPage(fileService, panelManager, fileOperations, keyboardService, pathHelper); + var window = new Window(new AppShell(mainPage)); + + // Обработка закрытия окна + window.Destroying += (s, e) => + { + // keyboardService?.Dispose(); + }; + + return window; } } \ No newline at end of file diff --git a/AppShell.xaml b/AppShell.xaml index f4857ae..b2f0ef4 100644 --- a/AppShell.xaml +++ b/AppShell.xaml @@ -3,12 +3,10 @@ x:Class="CommanderApp.AppShell" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" - xmlns:local="clr-namespace:CommanderApp" - Title="MAUI Comander"> + Title="MAUI Commander"> - diff --git a/AppShell.xaml.cs b/AppShell.xaml.cs index 64f0f20..87143a8 100644 --- a/AppShell.xaml.cs +++ b/AppShell.xaml.cs @@ -2,9 +2,10 @@ { public partial class AppShell : Shell { - public AppShell() + public AppShell(MainPage mainPage) { InitializeComponent(); + MainContent.Content = mainPage; } } } diff --git a/MainPage.xaml b/MainPage.xaml index 36ecfbe..3707378 100644 --- a/MainPage.xaml +++ b/MainPage.xaml @@ -1,8 +1,8 @@ - - + +