- jc_lvngstn
- Posts: 34
- Joined:
Buttons and OnMouseButtonDown - firing events.
It seems like Buttons do not fire the OnMouseButtonDown event, while Textblocks and labels do. Is this by design?
Thanks,
JC
Thanks,
JC
- golgepapaz
- Posts: 43
- Joined:
Re: Buttons and OnMouseButtonDown - firing events.
I believe the mousebuttondown events are converted OnClick events by the button control.
I use tunneling version of the events (PreviewMouseLeftButtonDown for example) in this case . Please read about Routed events and Tunneling&bubbling event.
I use tunneling version of the events (PreviewMouseLeftButtonDown for example) in this case . Please read about Routed events and Tunneling&bubbling event.
-
sfernandez
Site Admin
- Posts: 3095
- Joined:
Re: Buttons and OnMouseButtonDown - firing events.
As golgepapaz pointed, Button control handles MouseLeftButtonDown event to generate Click event. It is explained in the WPF documentation:
So you would need to attach to the PreviewMouseLeftButtonDown event if you want to be notified when user is trying to click the button.This implementation marks the MouseLeftButtonDown event as handled by setting the Handled property of the event data to true when ClickMode is not set to Hover. To respond to the MouseLeftButtonDown event, attach an event handler to the PreviewMouseLeftButtonDown event.
Who is online
Users browsing this forum: No registered users and 4 guests