Represents a single touch input produced by a finger on a touchscreen.
Assembly: PresentationCore (in PresentationCore.dll)
Thetype exposes the following members.
|ActiveSource||Gets the PresentationSource that is reporting input for this device. (Overrides InputDevice.ActiveSource.)|
|Captured||Gets the element that captured the .|
|CaptureMode||Gets the capture policy of the .|
|DirectlyOver||Gets the element that the touch contact point is directly over.|
|Dispatcher||Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)|
|Id||Gets the unique identifier of the , as provided by the operating system.|
|IsActive||Gets a value that indicates whether the device is active.|
|Target||Gets the element that receives input from the . (Overrides InputDevice.Target.)|
|Activate||Adds the to the input messaging system.|
|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.|
|CheckAccess||Determines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)|
|Deactivate||Removes the from the input messaging system.|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetIntermediateTouchPoints||When overridden in a derived class, returns all touch points that are collected between the most recent and previous touch events.|
|GetTouchPoint||Returns the current position of the touch device relative to the specified element.|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|OnCapture||Called when a touch is captured to an element.|
|OnManipulationEnded||Called when a manipulation has ended.|
|OnManipulationStarted||Called when a manipulation is started.|
|ReportDown||Reports that a touch is pressed on an element.|
|ReportMove||Reports that a touch is moving across an element.|
|ReportUp||Reports that a touch was lifted from an element.|
|SetActiveSource||Sets the PresentationSource that is reporting input for this device.|
|Synchronize||Forces the to synchronize the user interface with underlying touch points.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|VerifyAccess||Enforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)|
The following example enables you to create simple patterns on a Canvas by dragging two fingers on a touchscreen. Each touch is represented by a in the TouchEventArgs. The pattern is created by drawing a line between the touch points that are provided by the touches. This example requires a Windows Touch–compatible screen.
The following markup creates the user interface, which consists of a Canvas that is centered in a grid, and attaches the event handlers for the touch events.
<Window x:Class="WpfTouchEventsSample.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="525" Width="525"> <Grid> <Canvas x:Name="canvas1" Width="500" Height="500" Background="Black" TouchDown="canvas_TouchDown" TouchMove="canvas_TouchMove" TouchUp="canvas_TouchUp" /> </Grid> </Window>
The following code handles the touch events. When a touch is pressed on the Canvas, the is captured to the Canvas. When the touch is lifted, the is released. When a touch moves on the Canvas, the Id is checked. If the move came from 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.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.