Wpf: How to handle and then bubble events
I have an invisible button that fires a command when clicked but underneath it I have a control that is expecting to be dragged.But my button intercepts the 开发者_如何学Pythonevents so drag can't happen.
If I set IsHitTestVisible=false on the button then the control below it handles the drag correctly.
I'm wondering is it possible for my button to handle its click command but then somehow bubble the events?
So kind of like IsHitTestVisible=false but still have my button be able to process events..
I'm looking for a xaml only solution since this is done in app.xaml...
Thanks
I would consider using the Thumb primitive class instead of an invisible Button.
I would rather use an attached event, in this case "MouseDown", and attach it on the draggable control. This way when it's dragged, you'll fire the MouseDown event.
You can learn about attached events here for example, or any of the myriad of blogs talking about it ;)
Try using the PreviewMouseDown
event instead of MouseDown
event on your control to initiate the desired (drag) logic. This will work only if it's allowed that the drag logic will be executed before the command is fired.
Remember to set e.Handled=flase
in the handler so the Button
will have it's click.
精彩评论