I accidentally found this while working with my project, but I was able to reproduce this in a base project:
I open a MainWindow, then with ShowDialog a child window, Owner set to the Main. When I click on the Main, the Child starts to flash, then I start clicking between the Main and the Child very fast, and sometimes the Main gets the focus, then I able to open another Child window.
MainWindow:
<Window x:Class="WpfShowDialog.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="200" Width="300" WindowStartupLocation="CenterScreen" >
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" >
<TextBlock Text="MainWindow" Margin="10" />
<Button Content="Open child" Margin="10" Click="Button_Click" />
</StackPanel>
</Window>
Code behind:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var childWindow = new ChildWindow()
{
Owner = this
};
childWindow.ShowDialog();
}
}
ChildWindow:
<Window x:Class="WpfShowDialog.ChildWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ChildWindow" Height="150" Width="200" WindowStartupLocation="CenterOwner">
<Grid>
<TextBlock Text="ChildWindow" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
</Window>
Code behind:
public partial class ChildWindow : Window
{
public ChildWindow()
{
InitializeComponent();
}
}
I click on between these red circles:
Is this some kind of bug, or I miss something?