diff --git a/CRSim/MainWindow.xaml b/CRSim/MainWindow.xaml index 64f11a4..62c13d3 100644 --- a/CRSim/MainWindow.xaml +++ b/CRSim/MainWindow.xaml @@ -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"> diff --git a/CRSim/MainWindow.xaml.cs b/CRSim/MainWindow.xaml.cs index 141f20b..f6b71ec 100644 --- a/CRSim/MainWindow.xaml.cs +++ b/CRSim/MainWindow.xaml.cs @@ -43,5 +43,11 @@ public sealed partial class MainWindow : Window } } } + + private void Window_Activated(object sender, WindowActivatedEventArgs args) + { + var dialogService = App.AppHost.Services.GetService()!; + (dialogService as DialogService)?.SetXamlRoot(this.Content.XamlRoot); + } } } diff --git a/CRSim/ViewModels/PluginManagementPageViewModel.cs b/CRSim/ViewModels/PluginManagementPageViewModel.cs index 97ab75e..a747dd2 100644 --- a/CRSim/ViewModels/PluginManagementPageViewModel.cs +++ b/CRSim/ViewModels/PluginManagementPageViewModel.cs @@ -55,10 +55,6 @@ public partial class PluginManagementPageViewModel : ObservableObject await _dialogService.ShowTextAsync("安装失败", $"{ex}"); } } - else - { - await _dialogService.ShowMessageAsync("未选择文件", "请先选择一个插件包文件。"); - } } [RelayCommand] public void UninstallPlugin() diff --git a/CRSim/Views/StationManagementPage.xaml b/CRSim/Views/StationManagementPage.xaml index 0bf5a8f..dc63002 100644 --- a/CRSim/Views/StationManagementPage.xaml +++ b/CRSim/Views/StationManagementPage.xaml @@ -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}"> diff --git a/CRSim/Views/StationManagementPage.xaml.cs b/CRSim/Views/StationManagementPage.xaml.cs index 18e4674..d1bd8b0 100644 --- a/CRSim/Views/StationManagementPage.xaml.cs +++ b/CRSim/Views/StationManagementPage.xaml.cs @@ -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()!; - (dialogService as DialogService)?.SetXamlRoot(XamlRoot); - } }