当我在 WPF 中对 ShowDialog 进行两次调用时,第一个窗口正常打开,关闭后第二个窗口不出现。
<Application
x:Class="Test.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="App_OnStartup">
</Application>
private void App_OnStartup(object sender, StartupEventArgs e)
{
var windowA = new WindowA();
windowA.ShowDialog();
var windowB = new WindowB();
windowB.ShowDialog();
}
窗口A:
<Window x:Class="Test.WindowA"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowA" Height="129.452" Width="313.356">
<Grid>
<Button Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="139,54,0,0"/>
</Grid>
</Window>
public partial class WindowA : Window
{
public WindowA()
{
InitializeComponent();
}
}
窗口B:
<Window x:Class="Test.WindowB"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowB" Height="221.918" Width="300">
<Grid>
<RadioButton Content="RadioButton" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="124,63,0,0"/>
</Grid>
</Window>
public partial class WindowB : Window
{
public WindowB()
{
InitializeComponent();
}
}