简体   繁体   中英

C# WPF Controls within Controls and distinguishing LeftClick events!

I have UserControls within UserControls in WPF. This makes a tree structure starting from the root node.

I want to register for the event MouseLeftClickDown in all the UserControls. Left Clicking on a child control causes the event to fire for that control and all the parent controls that contain that child.

When I click a child, I don't want to fire the event for any parent controls, I just want it to fire for the child control clicked.

You could use the MouseDownEvent. The MouseEventArgs passed to the handler should have a Handled property that if it is set to true indicates that the event should not be passed on to the controls higher up in the hierarchy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM