Wpf event not bubbling

前端 未结 4 1438
野趣味
野趣味 2021-01-03 06:50

Here is my XAML:



        
4条回答
  •  無奈伤痛
    2021-01-03 07:02

    1. Try handling the PreviewMouseDown event instead. You can still attach that from XAML. In your handler

    2. Attach the event handler in code instead. Use the signature of AddHandler

    .

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
            Grid1.MouseUp += new MouseButtonEventHandler(Grid1_MouseUp);
    }
    private void Grid1_MouseUp(object sender, MouseButtonEventArgs e)
    {
            MessageBox.Show("Mouseup");
    }
    

提交回复
热议问题