fix: 插件管理无法弹出对话框

This commit is contained in:
denglihong2007
2025-07-30 20:42:48 +08:00
parent c91423ee48
commit c9f7961839
5 changed files with 9 additions and 12 deletions

View File

@@ -7,7 +7,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="国铁信息显示模拟">
Title="国铁信息显示模拟"
Activated="Window_Activated">
<Window.SystemBackdrop>
<MicaBackdrop />

View File

@@ -43,5 +43,11 @@ public sealed partial class MainWindow : Window
}
}
}
private void Window_Activated(object sender, WindowActivatedEventArgs args)
{
var dialogService = App.AppHost.Services.GetService<IDialogService>()!;
(dialogService as DialogService)?.SetXamlRoot(this.Content.XamlRoot);
}
}
}

View File

@@ -55,10 +55,6 @@ public partial class PluginManagementPageViewModel : ObservableObject
await _dialogService.ShowTextAsync("安装失败", $"{ex}");
}
}
else
{
await _dialogService.ShowMessageAsync("未选择文件", "请先选择一个插件包文件。");
}
}
[RelayCommand]
public void UninstallPlugin()

View File

@@ -12,8 +12,7 @@
xmlns:winui="using:CommunityToolkit.WinUI"
xmlns:viewmodels="using:CRSim.ViewModels"
xmlns:models="using:CRSim.Models"
xmlns:coremodels="using:CRSim.Core.Models"
Loaded="Page_Loaded"
xmlns:coremodels="using:CRSim.Core.Models"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewmodels:StationManagementPageViewModel}">
<Page.Resources>

View File

@@ -9,9 +9,4 @@ public sealed partial class StationManagementPage : Page
InitializeComponent();
DataContext = ViewModel;
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
var dialogService = App.AppHost.Services.GetService<IDialogService>()!;
(dialogService as DialogService)?.SetXamlRoot(XamlRoot);
}
}