2

Is there an equivalent to Javascript's event.preventDefault() in C# (using wpf)?

I want to prevent the default behavior when left clicking anywhere in the screen.

private void Button_MouseDown(object sender, MouseButtonEventArgs e){
    // I want to use something like Javascript's e.preventDefault()
}
Mohamed Khamis
  • 7,731
  • 10
  • 38
  • 58
  • e.Handled = true ? You may want to do that on PreviewMouseDown event. You could also disable the top Parent, all children wouldn't respond to mouse events – nkoniishvt Jan 21 '16 at 12:32
  • Check [this](http://stackoverflow.com/questions/9860306/intercepting-and-cancelling-the-click-event-of-a-winforms-button) – Faisal Jan 21 '16 at 12:36

1 Answers1

3

You might want to try e.Handled = true like so:

private void Button_MouseDown(object sender, MouseButtonEventArgs e){
    e.Handled = true;
}  
Exxoff
  • 161
  • 1
  • 9