2

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:

click locations

Is this some kind of bug, or I miss something?

Attila
  • 63
  • 2
  • 6
  • `clicking between the Main and the Child very fast` seems quite subjective. When you click do you aim for the button that launches the child window? Do you go back and forth between the frames? I'm not quite understanding the problem here. – crthompson Apr 16 '15 at 19:39
  • What do you mean exactly with _clicking between the Main and the Child_? I tried to reproduce your issue, but I had no success. What .NET Framework Version do you use? – Koopakiller Apr 16 '15 at 19:40
  • The problem is I call the Child to be modal, but if I can go back to Main, that's a problem. I use .NET 4.5.1. – Attila Apr 16 '15 at 19:44
  • Added a screenshot with the positions of the clicks. Under `very fast` I meant while the Child is flashing. – Attila Apr 16 '15 at 19:52
  • Using Win7? Try setting the child window's ShowInTaskbar property to false. – Hans Passant Apr 16 '15 at 20:01
  • I'm using Win 8.1. Tried `ShowInTaskbar="False"`, but the same. – Attila Apr 16 '15 at 20:16
  • I tried to reproduce, but no success. – Sriram Sakthivel Apr 16 '15 at 20:44
  • It's rare I admit, 1 in 10-15 tries maybe. Tried to record it with screen capture but I haven't able to yet. – Attila Apr 16 '15 at 20:46

0 Answers0