Allow Pointer events to bubble from Button clicks

故事扮演 提交于 2020-01-25 15:18:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!