问题
What steps to I need to take to enable Pointer events such as PointerPressed and PointerMoved to fire on a Container element when Buttons inside the container are clicked?
回答1:
The approach I ended up taking was to add event handlers to the container, and set the bool handledEventsToo parameter to true.
mainPage.AddHandler(PointerPressedEvent, new PointerEventHandler(pointerPressedHandler), true);
mainPage.AddHandler(PointerMovedEvent, new PointerEventHandler(pointerMovedHandler), true);
This means the container still gets a chance to process the events even if they have already been handled.
回答2:
Create a custom button control. Grab the template of a regular button and handle the events yourself - then you will be able to route it.
来源:https://stackoverflow.com/questions/13171124/allow-pointer-events-to-bubble-from-button-clicks