开发者

WPF Window routes clicks to the window behind when closing!

开发者 https://www.devze.com 2023-03-06 02:12 出处:网络
private void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e) { App.Current.MainWindow.Visibility = System.Windows.Visibility.Visible;
    private void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
        App.Current.MainWindow.Visibility = System.Windows.Visibility.Visible;
        Close();
    }

A click/click event is also send to any window behind...

Even this bugs...

    private void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
        App.Current.MainWindow.Visibility = System.Windows.Visibility开发者_JAVA百科.Visible;
        System.Threading.Thread.Sleep(500);
        Close();
    }


MouseDoubleClick is a direct routed event, and as such even setting e.Handled = true will not affect subsequent events up the tree. The suggested method for handling a double-click is to handle MouseLeftButtonDown, and check for ClickCount == 2. You can then set e.Handled = true, which should prevent the event from bubbling.

0

精彩评论

暂无评论...
验证码 换一张
取 消