diff --git a/MainWindow.xaml b/MainWindow.xaml index 278679f..6c0388d 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -287,7 +287,7 @@ + Width="140" Height="40" BorderThickness="0" Margin="8,5" Cursor="Hand" Click="Button_Click_8"/> + \ No newline at end of file diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 2b76aee..9978f1c 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -14,6 +14,7 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; +using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; @@ -636,6 +637,11 @@ namespace 自救器呼吸器综合检验仪 { } + + private void Button_Click_8(object sender, RoutedEventArgs e) + { + + } } diff --git a/MainWindow2.xaml b/MainWindow2.xaml index 3e413c1..cf39021 100644 --- a/MainWindow2.xaml +++ b/MainWindow2.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:自救器呼吸器综合检验仪" - Title="自救器呼吸器综合检验仪" Height="768" Width="1024" + Title="自救器呼吸器综合检验仪" Height="730" Width="1024" WindowStartupLocation="CenterScreen" Background="Transparent" FontFamily="Microsoft YaHeui" Loaded="Window_Loaded" Closed="Window_Closed" Closing="Window_Closing"> diff --git a/MainWindow2.xaml.cs b/MainWindow2.xaml.cs index 0a98cd9..2697f35 100644 --- a/MainWindow2.xaml.cs +++ b/MainWindow2.xaml.cs @@ -17,6 +17,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Threading; +using System.Windows.Media.Animation; using 自救器呼吸器综合检验仪; using 自救器呼吸器综合检验仪.Data; @@ -478,44 +479,55 @@ namespace 自救器呼吸器综合检验仪 private void SwitchWindow(ref T windowInstance, Func createFunc) where T : Window, new() { - // 1. 停止当前窗口的定时器(不释放资源) _readTimer?.Stop(); - // 2. 检查资源是否可用(添加重连机制) if (_tcpClient == null || !_tcpClient.Connected || _modbusMaster == null) { - // 尝试重新连接 - bool reconnectSuccess = TryReconnect(); - if (!reconnectSuccess) + if (!TryReconnect()) { MessageBox.Show("TCP连接已断开,请重新连接!", "提示"); return; } } - // 3. 复用窗口实例:不存在则创建,存在则激活 + void ShowTargetWindow(T target) + { + if (target.IsVisible) + { + target.Activate(); + this.Hide(); + return; + } + + target.Opacity = 0; + void OnContentRendered(object s, EventArgs e) + { + target.ContentRendered -= OnContentRendered; + var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200)); + target.BeginAnimation(Window.OpacityProperty, anim); + this.Hide(); + target.Activate(); + } + + target.ContentRendered += OnContentRendered; + target.Show(); + } + if (windowInstance == null) { windowInstance = createFunc(); - // 添加窗口关闭事件处理 windowInstance.Closed += (s, args) => { - // 窗口关闭时重新启动定时器并显示当前窗口 _readTimer?.Start(); - //this.Show(); this.Activate(); }; + + ShowTargetWindow(windowInstance); } else { - // 激活已存在的窗口(前置显示) - windowInstance.Activate(); - //return; + ShowTargetWindow(windowInstance); } - - // 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态) - this.Hide(); - windowInstance.Show(); // 使用 Show() 而不是 ShowDialog() } // 添加重连方法 private bool TryReconnect() @@ -643,7 +655,7 @@ namespace 自救器呼吸器综合检验仪 } string No = ConfigurationManager.AppSettings["No"]?.ToString(); // 添加记录到窗口(无论窗口是否显示) - _reportWindow2.AddRecord(currentTime, currentDate, startPress, endPress, diffPress, ProtectTime,No); + _reportWindow2.AddRecord(currentTime, currentDate, startPress, endPress, diffPress, ProtectTime, No); }); } @@ -730,7 +742,7 @@ namespace 自救器呼吸器综合检验仪 //} } - + public class TestRecordForNegativePressure { diff --git a/MainWindow3.xaml b/MainWindow3.xaml index d7af541..128ca67 100644 --- a/MainWindow3.xaml +++ b/MainWindow3.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:自救器呼吸器综合检验仪" - Title="自救器呼吸器综合检验仪" Height="768" Width="1024" + Title="自救器呼吸器综合检验仪" Height="730" Width="1024" WindowStartupLocation="CenterScreen" Background="Transparent" FontFamily="Microsoft YaHeui" diff --git a/MainWindow3.xaml.cs b/MainWindow3.xaml.cs index 6197fe7..d4d0d0c 100644 --- a/MainWindow3.xaml.cs +++ b/MainWindow3.xaml.cs @@ -17,6 +17,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Threading; +using System.Windows.Media.Animation; using 自救器呼吸器综合检验仪; using 自救器呼吸器综合检验仪.Data; @@ -451,44 +452,55 @@ namespace 自救器呼吸器综合检验仪 private void SwitchWindow(ref T windowInstance, Func createFunc) where T : Window, new() { - // 1. 停止当前窗口的定时器(不释放资源) _readTimer?.Stop(); - // 2. 检查资源是否可用(添加重连机制) if (_tcpClient == null || !_tcpClient.Connected || _modbusMaster == null) { - // 尝试重新连接 - bool reconnectSuccess = TryReconnect(); - if (!reconnectSuccess) + if (!TryReconnect()) { MessageBox.Show("TCP连接已断开,请重新连接!", "提示"); return; } } - // 3. 复用窗口实例:不存在则创建,存在则激活 + void ShowTargetWindow(T target) + { + if (target.IsVisible) + { + target.Activate(); + this.Hide(); + return; + } + + target.Opacity = 0; + void OnContentRendered(object s, EventArgs e) + { + target.ContentRendered -= OnContentRendered; + var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200)); + target.BeginAnimation(Window.OpacityProperty, anim); + this.Hide(); + target.Activate(); + } + + target.ContentRendered += OnContentRendered; + target.Show(); + } + if (windowInstance == null) { windowInstance = createFunc(); - // 添加窗口关闭事件处理 windowInstance.Closed += (s, args) => { - // 窗口关闭时重新启动定时器并显示当前窗口 _readTimer?.Start(); - //this.Show(); this.Activate(); }; + + ShowTargetWindow(windowInstance); } else { - // 激活已存在的窗口(前置显示) - windowInstance.Activate(); - //return; + ShowTargetWindow(windowInstance); } - - // 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态) - this.Hide(); - windowInstance.Show(); // 使用 Show() 而不是 ShowDialog() } // 添加重连方法 private bool TryReconnect() diff --git a/MainWindow4.xaml b/MainWindow4.xaml index b07c3f3..02ae341 100644 --- a/MainWindow4.xaml +++ b/MainWindow4.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:自救器呼吸器综合检验仪" - Title="自救器呼吸器综合检验仪" Height="768" Width="1024" + Title="自救器呼吸器综合检验仪" Height="730" Width="1024" WindowStartupLocation="CenterScreen" Background="Transparent" FontFamily="Microsoft YaHeui" diff --git a/MainWindow4.xaml.cs b/MainWindow4.xaml.cs index 74a6dd8..0bc2a4d 100644 --- a/MainWindow4.xaml.cs +++ b/MainWindow4.xaml.cs @@ -17,6 +17,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Threading; +using System.Windows.Media.Animation; using 自救器呼吸器综合检验仪; using 自救器呼吸器综合检验仪.Data; @@ -296,44 +297,55 @@ namespace 自救器呼吸器综合检验仪 private void SwitchWindow(ref T windowInstance, Func createFunc) where T : Window, new() { - // 1. 停止当前窗口的定时器(不释放资源) _readTimer?.Stop(); - // 2. 检查资源是否可用(添加重连机制) if (_tcpClient == null || !_tcpClient.Connected || _modbusMaster == null) { - // 尝试重新连接 - bool reconnectSuccess = TryReconnect(); - if (!reconnectSuccess) + if (!TryReconnect()) { MessageBox.Show("TCP连接已断开,请重新连接!", "提示"); return; } } - // 3. 复用窗口实例:不存在则创建,存在则激活 + void ShowTargetWindow(T target) + { + if (target.IsVisible) + { + target.Activate(); + this.Hide(); + return; + } + + target.Opacity = 0; + void OnContentRendered(object s, EventArgs e) + { + target.ContentRendered -= OnContentRendered; + var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200)); + target.BeginAnimation(Window.OpacityProperty, anim); + this.Hide(); + target.Activate(); + } + + target.ContentRendered += OnContentRendered; + target.Show(); + } + if (windowInstance == null) { windowInstance = createFunc(); - // 添加窗口关闭事件处理 windowInstance.Closed += (s, args) => { - // 窗口关闭时重新启动定时器并显示当前窗口 _readTimer?.Start(); - //this.Show(); this.Activate(); }; + + ShowTargetWindow(windowInstance); } else { - // 激活已存在的窗口(前置显示) - windowInstance.Activate(); - //return; + ShowTargetWindow(windowInstance); } - - // 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态) - this.Hide(); - windowInstance.Show(); // 使用 Show() 而不是 ShowDialog() } private bool TryReconnect() { diff --git a/ParameterSettingsWindow.xaml b/ParameterSettingsWindow.xaml index 08e80b4..8f1869f 100644 --- a/ParameterSettingsWindow.xaml +++ b/ParameterSettingsWindow.xaml @@ -1,7 +1,7 @@ diff --git a/ParameterSettingsWindow.xaml.cs b/ParameterSettingsWindow.xaml.cs index 14a5313..5ab145a 100644 --- a/ParameterSettingsWindow.xaml.cs +++ b/ParameterSettingsWindow.xaml.cs @@ -6,6 +6,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Threading; +using System.Windows.Media.Animation; using 自救器呼吸器综合检验仪.Data; namespace 自救器呼吸器综合检验仪 @@ -118,44 +119,57 @@ namespace 自救器呼吸器综合检验仪 private void SwitchWindow(ref T windowInstance, Func createFunc) where T : Window, new() { - // 1. 停止当前窗口的定时器(不释放资源) + // 停止当前窗口的定时器(不释放资源) _readTimer?.Stop(); - // 2. 检查资源是否可用(添加重连机制) if (_tcpClient == null || !_tcpClient.Connected || _modbusMaster == null) { - // 尝试重新连接 - bool reconnectSuccess = TryReconnect(); - if (!reconnectSuccess) + if (!TryReconnect()) { MessageBox.Show("TCP连接已断开,请重新连接!", "提示"); return; } } - // 3. 复用窗口实例:不存在则创建,存在则激活 + void ShowTargetWindow(T target) + { + if (target.IsVisible) + { + target.Activate(); + this.Hide(); + return; + } + + target.Opacity = 0; + void OnContentRendered(object s, EventArgs e) + { + target.ContentRendered -= OnContentRendered; + var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200)); + target.BeginAnimation(Window.OpacityProperty, anim); + this.Hide(); + target.Activate(); + } + + target.ContentRendered += OnContentRendered; + target.Show(); + } + if (windowInstance == null) { windowInstance = createFunc(); - // 添加窗口关闭事件处理 windowInstance.Closed += (s, args) => { - // 窗口关闭时重新启动定时器并显示当前窗口 _readTimer?.Start(); this.Show(); this.Activate(); }; + + ShowTargetWindow(windowInstance); } else { - // 激活已存在的窗口(前置显示) - windowInstance.Activate(); - return; + ShowTargetWindow(windowInstance); } - - // 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态) - this.Hide(); - windowInstance.Show(); // 使用 Show() 而不是 ShowDialog() } diff --git a/ReportWindow.xaml b/ReportWindow.xaml index 58c78be..2e08ffe 100644 --- a/ReportWindow.xaml +++ b/ReportWindow.xaml @@ -1,7 +1,7 @@ diff --git a/ReportWindow.xaml.cs b/ReportWindow.xaml.cs index 03494b6..6ec7164 100644 --- a/ReportWindow.xaml.cs +++ b/ReportWindow.xaml.cs @@ -10,6 +10,7 @@ using System.Text; using System.Windows; using System.Windows.Controls; using 自救器呼吸器综合检验仪.Data; +using System.Windows.Media.Animation; namespace 自救器呼吸器综合检验仪 { @@ -230,6 +231,14 @@ namespace 自救器呼吸器综合检验仪 private void BtnPrint_Click(object sender, RoutedEventArgs e) { + // 判断是否有数据可打印 + if (_records == null || _records.Count == 0) + { + MessageBox.Show("当前没有可打印的数据。", "提示", MessageBoxButton.OK, MessageBoxImage.Information); + return; + } + + // 触发打印/硬件动作 ma.BtnClickFunctionForNew(Function.ButtonType.切换型, 15); } @@ -254,42 +263,53 @@ namespace 自救器呼吸器综合检验仪 private void SwitchWindow(ref T windowInstance, Func createFunc) where T : Window, new() { - - // 2. 检查资源是否可用(添加重连机制) if (_tcpClient == null || !_tcpClient.Connected || _modbusMaster == null) { - // 尝试重新连接 - bool reconnectSuccess = TryReconnect(); - if (!reconnectSuccess) + if (!TryReconnect()) { MessageBox.Show("TCP连接已断开,请重新连接!", "提示"); return; } } - // 3. 复用窗口实例:不存在则创建,存在则激活 + void ShowTargetWindow(T target) + { + if (target.IsVisible) + { + target.Activate(); + this.Hide(); + return; + } + + target.Opacity = 0; + void OnContentRendered(object s, EventArgs e) + { + target.ContentRendered -= OnContentRendered; + var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200)); + target.BeginAnimation(Window.OpacityProperty, anim); + this.Hide(); + target.Activate(); + } + + target.ContentRendered += OnContentRendered; + target.Show(); + } + if (windowInstance == null) { windowInstance = createFunc(); - // 添加窗口关闭事件处理 windowInstance.Closed += (s, args) => { - // 窗口关闭时重新启动定时器并显示当前窗口 - this.Show(); this.Activate(); }; + + ShowTargetWindow(windowInstance); } else { - // 激活已存在的窗口(前置显示) - windowInstance.Activate(); - return; + ShowTargetWindow(windowInstance); } - - // 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态) - this.Hide(); - windowInstance.Show(); // 使用 Show() 而不是 ShowDialog() } private void BtnClose_Click(object sender, RoutedEventArgs e) diff --git a/ReportWindow2.xaml b/ReportWindow2.xaml index 0a685d5..83784cc 100644 --- a/ReportWindow2.xaml +++ b/ReportWindow2.xaml @@ -1,7 +1,7 @@ diff --git a/ReportWindow2.xaml.cs b/ReportWindow2.xaml.cs index b1035f0..a58752f 100644 --- a/ReportWindow2.xaml.cs +++ b/ReportWindow2.xaml.cs @@ -10,6 +10,7 @@ using System.Text; using System.Windows; using System.Windows.Controls; using 自救器呼吸器综合检验仪.Data; +using System.Windows.Media.Animation; namespace 自救器呼吸器综合检验仪 { @@ -250,6 +251,12 @@ namespace 自救器呼吸器综合检验仪 private void BtnPrint_Click(object sender, RoutedEventArgs e) { + // 判断是否有数据可打印 + if (_records == null || _records.Count == 0) + { + MessageBox.Show("当前没有可打印的数据。", "提示", MessageBoxButton.OK, MessageBoxImage.Information); + return; + } ma.BtnClickFunctionForNew(Function.ButtonType.切换型, 15); } @@ -274,42 +281,53 @@ namespace 自救器呼吸器综合检验仪 private void SwitchWindow(ref T windowInstance, Func createFunc) where T : Window, new() { - - // 2. 检查资源是否可用(添加重连机制) if (_tcpClient == null || !_tcpClient.Connected || _modbusMaster == null) { - // 尝试重新连接 - bool reconnectSuccess = TryReconnect(); - if (!reconnectSuccess) + if (!TryReconnect()) { MessageBox.Show("TCP连接已断开,请重新连接!", "提示"); return; } } - // 3. 复用窗口实例:不存在则创建,存在则激活 + void ShowTargetWindow(T target) + { + if (target.IsVisible) + { + target.Activate(); + this.Hide(); + return; + } + + target.Opacity = 0; + void OnContentRendered(object s, EventArgs e) + { + target.ContentRendered -= OnContentRendered; + var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200)); + target.BeginAnimation(Window.OpacityProperty, anim); + this.Hide(); + target.Activate(); + } + + target.ContentRendered += OnContentRendered; + target.Show(); + } + if (windowInstance == null) { windowInstance = createFunc(); - // 添加窗口关闭事件处理 windowInstance.Closed += (s, args) => { - // 窗口关闭时重新启动定时器并显示当前窗口 - this.Show(); this.Activate(); }; + + ShowTargetWindow(windowInstance); } else { - // 激活已存在的窗口(前置显示) - windowInstance.Activate(); - return; + ShowTargetWindow(windowInstance); } - - // 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态) - this.Hide(); - windowInstance.Show(); // 使用 Show() 而不是 ShowDialog() } private void BtnClose_Click(object sender, RoutedEventArgs e) diff --git a/ReportWindow3.xaml b/ReportWindow3.xaml index ec7c4e4..70395bd 100644 --- a/ReportWindow3.xaml +++ b/ReportWindow3.xaml @@ -1,7 +1,7 @@ diff --git a/ReportWindow3.xaml.cs b/ReportWindow3.xaml.cs index cf53515..f25af82 100644 --- a/ReportWindow3.xaml.cs +++ b/ReportWindow3.xaml.cs @@ -10,6 +10,7 @@ using System.Text; using System.Windows; using System.Windows.Controls; using 自救器呼吸器综合检验仪.Data; +using System.Windows.Media.Animation; namespace 自救器呼吸器综合检验仪 { @@ -191,6 +192,12 @@ namespace 自救器呼吸器综合检验仪 private void BtnPrint_Click(object sender, RoutedEventArgs e) { + // 判断是否有数据可打印 + if (_records == null || _records.Count == 0) + { + MessageBox.Show("当前没有可打印的数据。", "提示", MessageBoxButton.OK, MessageBoxImage.Information); + return; + } ma.BtnClickFunctionForNew(Function.ButtonType.切换型, 15); } @@ -272,42 +279,53 @@ namespace 自救器呼吸器综合检验仪 private void SwitchWindow(ref T windowInstance, Func createFunc) where T : Window, new() { - - // 2. 检查资源是否可用(添加重连机制) if (_tcpClient == null || !_tcpClient.Connected || _modbusMaster == null) { - // 尝试重新连接 - bool reconnectSuccess = TryReconnect(); - if (!reconnectSuccess) + if (!TryReconnect()) { MessageBox.Show("TCP连接已断开,请重新连接!", "提示"); return; } } - // 3. 复用窗口实例:不存在则创建,存在则激活 + void ShowTargetWindow(T target) + { + if (target.IsVisible) + { + target.Activate(); + this.Hide(); + return; + } + + target.Opacity = 0; + void OnContentRendered(object s, EventArgs e) + { + target.ContentRendered -= OnContentRendered; + var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200)); + target.BeginAnimation(Window.OpacityProperty, anim); + this.Hide(); + target.Activate(); + } + + target.ContentRendered += OnContentRendered; + target.Show(); + } + if (windowInstance == null) { windowInstance = createFunc(); - // 添加窗口关闭事件处理 windowInstance.Closed += (s, args) => { - // 窗口关闭时重新启动定时器并显示当前窗口 - this.Show(); this.Activate(); }; + + ShowTargetWindow(windowInstance); } else { - // 激活已存在的窗口(前置显示) - windowInstance.Activate(); - return; + ShowTargetWindow(windowInstance); } - - // 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态) - this.Hide(); - windowInstance.Show(); // 使用 Show() 而不是 ShowDialog() } private void BtnClose_Click(object sender, RoutedEventArgs e) diff --git a/ReportWindow4.xaml b/ReportWindow4.xaml index 2d0fb64..b4ea251 100644 --- a/ReportWindow4.xaml +++ b/ReportWindow4.xaml @@ -1,7 +1,7 @@ diff --git a/ReportWindow4.xaml.cs b/ReportWindow4.xaml.cs index 3f677d9..37c5507 100644 --- a/ReportWindow4.xaml.cs +++ b/ReportWindow4.xaml.cs @@ -10,6 +10,7 @@ using System.Text; using System.Windows; using System.Windows.Controls; using 自救器呼吸器综合检验仪.Data; +using System.Windows.Media.Animation; namespace 自救器呼吸器综合检验仪 { @@ -233,6 +234,12 @@ namespace 自救器呼吸器综合检验仪 private void BtnPrint_Click(object sender, RoutedEventArgs e) { + // 判断是否有数据可打印 + if (_records == null || _records.Count == 0) + { + MessageBox.Show("当前没有可打印的数据。", "提示", MessageBoxButton.OK, MessageBoxImage.Information); + return; + } ma.BtnClickFunctionForNew(Function.ButtonType.切换型, 15); } @@ -313,42 +320,53 @@ namespace 自救器呼吸器综合检验仪 private void SwitchWindow(ref T windowInstance, Func createFunc) where T : Window, new() { - - // 2. 检查资源是否可用(添加重连机制) if (_tcpClient == null || !_tcpClient.Connected || _modbusMaster == null) { - // 尝试重新连接 - bool reconnectSuccess = TryReconnect(); - if (!reconnectSuccess) + if (!TryReconnect()) { MessageBox.Show("TCP连接已断开,请重新连接!", "提示"); return; } } - // 3. 复用窗口实例:不存在则创建,存在则激活 + void ShowTargetWindow(T target) + { + if (target.IsVisible) + { + target.Activate(); + this.Hide(); + return; + } + + target.Opacity = 0; + void OnContentRendered(object s, EventArgs e) + { + target.ContentRendered -= OnContentRendered; + var anim = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200)); + target.BeginAnimation(Window.OpacityProperty, anim); + this.Hide(); + target.Activate(); + } + + target.ContentRendered += OnContentRendered; + target.Show(); + } + if (windowInstance == null) { windowInstance = createFunc(); - // 添加窗口关闭事件处理 windowInstance.Closed += (s, args) => { - // 窗口关闭时重新启动定时器并显示当前窗口 - this.Show(); this.Activate(); }; + + ShowTargetWindow(windowInstance); } else { - // 激活已存在的窗口(前置显示) - windowInstance.Activate(); - return; + ShowTargetWindow(windowInstance); } - - // 4. 切换窗口:隐藏当前窗口,显示目标窗口(非模态) - this.Hide(); - windowInstance.Show(); // 使用 Show() 而不是 ShowDialog() } private void BtnClose_Click(object sender, RoutedEventArgs e)