Search code examples
c#wpfeventsbuttontunneling

WPF button tunneling OnClick event


I am looking for a tunneling Button.Click event. The ButtonBase.Click event is bubbling and therefore the root can handle the event only after the action that was registered for that button already occurred (too late for what I need).

I need the counterpart "preview" event, so that I can handle the event before the event that is registered to the button occurs.
I am not sure such event exists, so if it doens't I would be happy to hear some workarounds.


Solution

  • There is no Button.PreviewClick event. You might try using Button.PreviewMouseDown or Button.PreviewMouseUp to see if that would work for what you're trying to do.