TouchFrameEventArgs::GetPrimaryTouchPoint Method (IInputElement^)

.NET Framework (current version)
 

Returns the current touch point of the primary touch device relative to the specified element.

Namespace:   System.Windows.Input
Assembly:  PresentationCore (in PresentationCore.dll)

public:
TouchPoint^ GetPrimaryTouchPoint(
	IInputElement^ relativeTo
)

Parameters

relativeTo
Type: System.Windows::IInputElement^

The element that defines the coordinate space. To use WPF absolute coordinates, specify relativeTo as null.

Return Value

Type: System.Windows.Input::TouchPoint^

The current position of the primary TouchDevice relative to the specified element; or null if the primary TouchDevice is not active.

In a set of active touch devices, the first device to be Activated is the primary touch device. For example, if two fingers are touching the screen, the first finger that is down is represented by the primary touch device. If the first finger is lifted while the second finger is still down, the primary touch device becomes null.

The following code processes the touch points that are retrieved from the TouchFrameEventArgs. When a touch is pressed on the Canvas, the TouchDevice is captured to the Canvas. When the touch is lifted, the TouchDevice is released. When a touch moves across the Canvas, the Id is checked. If the Id matches the Id of the primary touch point, which indicates the first touch, its location is recorded. If the move came from the second touch, a line is drawn from the position of the first touch to the position of the second touch.

This example is part of a larger example that is available in the Touch class overview.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 4.0
Return to top
Show: