From c9f79618396a21e9f44ee3fa42d4525e169062f7 Mon Sep 17 00:00:00 2001 From: denglihong2007 <98096191+denglihong2007@users.noreply.github.com> Date: Wed, 30 Jul 2025 20:42:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=BC=B9=E5=87=BA=E5=AF=B9=E8=AF=9D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CRSim/MainWindow.xaml | 3 ++- CRSim/MainWindow.xaml.cs | 6 ++++++ CRSim/ViewModels/PluginManagementPageViewModel.cs | 4 ---- CRSim/Views/StationManagementPage.xaml | 3 +-- CRSim/Views/StationManagementPage.xaml.cs | 5 ----- 5 files changed, 9 insertions(+), 12 deletions(-) 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); - } }