WPF Window routes clicks to the window behind when closing!
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.
精彩评论