With the advent of Windows Phone, Silverlight transitioned from being a browser and desktop-only technology with a primarily mouse-driven UI, to a mobile device technology with a touch-driven UI.
To allow controls that were originally designed to work with mouse events to continue to function, the touch system was engineered so that touch events are automatically turned into (promoted to) mouse events. If a touch event is not suspended using the SuspendMousePromotionUntilTouchUp
method, then mouse events are automatically raised.
Note
Promotion of a TouchPoint
to a mouse event occurs only with the primary touch point.
To prevent a touch event from being promoted to a mouse event, call the SuspendMousePromotionUntilTouchUp
within the FrameReported
event handler, like so:
void HandleFrameReported(object sender, TouchFrameEventArgs e)
{
TouchPoint primaryTouchPoint = e.GetPrimaryTouchPoint(null);
if (primaryTouchPoint != null
&& primaryTouchPoint.Action == TouchAction.Down)
{
e.SuspendMousePromotionUntilTouchUp();
/* custom code */
}
}
The SuspendMousePromotionUntilTouchUp
method can be called only when the TouchPoint.Action
property is equal to TouchAction.Down
, or else an InvalidOperationException
is raised.
In most cases, calling SuspendMousePromotionUntilTouchUp
is something you should avoid, because doing so prevents the functioning of any controls that rely solely on mouse events and those that have not been built using the touch-specific API.
52.15.179.139