правка создания

main
Пилипенко Андрей Борисович 3 weeks ago
parent f630287d35
commit 354adb75da

@ -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<MainPage>();
}
private void ConfigureServices(ServiceCollection services)
protected override Window CreateWindow(IActivationState? activationState)
{
services.AddSingleton<IFileSystemService, FileSystemService>();
services.AddSingleton<IPanelManager, PanelManager>();
services.AddSingleton<IFileOperations, FileOperations>();
services.AddSingleton<IKeyboardService, KeyboardService>();
services.AddSingleton<IPathHelper, PathHelper>();
services.AddSingleton<MainPage>();
// Создаем сервисы непосредственно в 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;
}
}

@ -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">
<ShellContent
x:Name="MainContent"
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
</Shell>

@ -2,9 +2,10 @@
{
public partial class AppShell : Shell
{
public AppShell()
public AppShell(MainPage mainPage)
{
InitializeComponent();
MainContent.Content = mainPage;
}
}
}

@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CommanderApp.MainPage"
Title="MAUI Commander">
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CommanderApp.MainPage"
Title="MAUI Commander">
<Grid RowDefinitions="Auto, Auto, *, Auto" ColumnDefinitions="*, *">
<!-- Пути -->

Loading…
Cancel
Save