Skip to content

Latest commit

 

History

History
46 lines (29 loc) · 4.15 KB

uielement_releasepointercapture_851958174.md

File metadata and controls

46 lines (29 loc) · 4.15 KB
-api-id -api-type
M:Microsoft.UI.Xaml.UIElement.ReleasePointerCapture(Microsoft.UI.Xaml.Input.Pointer)
winrt method

Microsoft.UI.Xaml.UIElement.ReleasePointerCapture

-description

Releases pointer captures for capture of one specific pointer by this UIElement.

-parameters

-param value

The pointer reference. Use either saved references from previous captures, or pointer event data, to obtain this reference.

-remarks

Programmatically releasing the pointer capture with ReleasePointerCapture is not the only way that an element might lose pointer capture. For example, user-driven events such as releasing the pointer (touch point up, mouse button released) can cause the pointer capture to be canceled.

You can listen for the PointerCaptureLostevent to determine when this happens.

Another way that pointer capture might be canceled is if a pointer moves out of one app and into another app while the two apps are side-by-side.

You should only call ReleasePointerCapture if your app code has previously called CapturePointer, and has a reference to the particular Pointer instance where you want to release the pointer capture. You'd typically get that Pointer reference through an event such as PointerReleased or perhaps PointerMoved.

Your app code might call CapturePointer from a different UIElement than the one that has any current pointer capture. If so, that cancels any pointer capture previously made by other elements.

A UIElementcan capture multiple pointers to handle multiple touch points such as for manipulations, but only one UIElement in an app can have any pointer captures at any one time. For more info, see Handle pointer input.

-examples

This example shows calling ReleasePointerCapture based on handling PointerReleased.

It also shows code for capturing the pointer initially, and a pattern for tracking and counting pointer references.

[!code-csharpScenario2Code]

-see-also

Microsoft.UI.Xaml.UIElement.ReleasePointerCaptures, CapturePointer, PointerReleased, PointerCaptureLost, Relative mouse movement and CoreWindow, Input sample