Muokkaa

Jaa


TouchDevice.Capture Method

Definition

Captures a touch to the specified element.

Overloads

Capture(IInputElement)

Captures a touch to the specified element by using the Element capture mode.

Capture(IInputElement, CaptureMode)

Captures a touch to the specified element by using the specified CaptureMode.

Capture(IInputElement)

Captures a touch to the specified element by using the Element capture mode.

public:
 bool Capture(System::Windows::IInputElement ^ element);
public bool Capture (System.Windows.IInputElement element);
member this.Capture : System.Windows.IInputElement -> bool
Public Function Capture (element As IInputElement) As Boolean

Parameters

element
IInputElement

The element that captures the touch input.

Returns

true if the element was able to capture the touch; otherwise, false.

Exceptions

Examples

The following example handles the TouchDown events that occur on a Canvas. When a touch is pressed on the Canvas, the TouchDevice is captured to the Canvas.

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

private void canvas_TouchDown(object sender, TouchEventArgs e)
{
    Canvas _canvas = (Canvas)sender as Canvas;
    if (_canvas != null)
    {
        _canvas.Children.Clear();
        e.TouchDevice.Capture(_canvas);

        // Record the ID of the first touch point if it hasn't been recorded.
        if (firstTouchId == -1)
            firstTouchId = e.TouchDevice.Id;
    }
}
' Touch Down
Private Sub canvas_TouchDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.TouchEventArgs)
    Dim _canvas As Canvas = CType(sender, Canvas)
    If (_canvas IsNot Nothing) Then
        _canvas.Children.Clear()
        e.TouchDevice.Capture(_canvas)

        ' Record the ID of the first touch point if it hasn't been recorded.
        If firstTouchId = -1 Then
            firstTouchId = e.TouchDevice.Id
        End If
    End If
End Sub

Remarks

A TouchDevice cannot be captured to an element if it is already captured to another element.

Applies to

Capture(IInputElement, CaptureMode)

Captures a touch to the specified element by using the specified CaptureMode.

public:
 bool Capture(System::Windows::IInputElement ^ element, System::Windows::Input::CaptureMode captureMode);
public bool Capture (System.Windows.IInputElement element, System.Windows.Input.CaptureMode captureMode);
member this.Capture : System.Windows.IInputElement * System.Windows.Input.CaptureMode -> bool
Public Function Capture (element As IInputElement, captureMode As CaptureMode) As Boolean

Parameters

element
IInputElement

The element that captures the touch.

captureMode
CaptureMode

The capture policy to use.

Returns

true if the element was able to capture the touch; otherwise, false.

Exceptions

Remarks

A TouchDevice cannot be captured to an element if it is already captured to another element.

Applies to