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.