Reputation: 10234
I have a Grid
with a Button
inside. The button has Flyout
menu attached.
I implemented an action which opens the flyout menu when the button is tapped/clicked. This is the default behavior which does not require event writing. I also implemented an action when the grid is tapped/clicked.
The problem is that I do not want the grid to react when I tap/click the button. Based on this fine read, it all makes sense, but in my case, I do not have any code behind to add the e.Handled = true;
line to.
Is there any way I could stop event bubbling up the tree using XAML
only? Thanks!
Upvotes: 2
Views: 1551
Reputation: 23270
While I hate to poach Gusdor's points. There is a built an enumeration property to deal with this types of situations called ClickMode which you can override the default mode for Button
of Release
and set it at the instance as ClickMode="Press"
to get the desired effect and allow it to receive HitTestVisibility individually before any parent does.
Hope this helps, cheers.
Upvotes: 2
Reputation: 14334
I believe you will need to write some code but not the code behind you are trying to avoid.
There is a Microsoft article about plugging Behaviours into UWP apps https://blogs.windows.com/buildingapps/2015/11/30/xaml-behaviors-open-source-and-on-uwp/
Upvotes: 0