TouchDevice.Captured 属性

定义

获取捕获了 TouchDevice 的元素。

public:
 property System::Windows::IInputElement ^ Captured { System::Windows::IInputElement ^ get(); };
public System.Windows.IInputElement Captured { get; }
member this.Captured : System.Windows.IInputElement
Public ReadOnly Property Captured As IInputElement

属性值

捕获了 TouchDevice 的元素。

示例

以下示例处理 TouchUp 在 上 Canvas发生的事件。 它检查 属性以 Captured 验证引发 事件的设备是否已捕获到 Canvas。 如果为 , TouchDevice 则释放 。

此示例是类概述中提供的更大示例的一 TouchDevice 部分。

private void canvas_TouchUp(object sender, TouchEventArgs e)
{
    Canvas _canvas = (Canvas)sender as Canvas;
    if (_canvas != null && e.TouchDevice.Captured == _canvas)
    {
        _canvas.ReleaseTouchCapture(e.TouchDevice);
    }
}
' Touch Up
Private Sub canvas_TouchUp(ByVal sender As System.Object, ByVal e As System.Windows.Input.TouchEventArgs)
    Dim _canvas As Canvas = CType(sender, Canvas)
    If (_canvas IsNot Nothing AndAlso e.TouchDevice.Captured Is _canvas) Then
        _canvas.ReleaseTouchCapture(e.TouchDevice)

    End If
End Sub

适用于