Touch Class

Provides an application-level service that processes multitouch input from the operating system and raises the FrameReported event.


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

type Touch =  class end

The Touch type exposes the following members.

Public eventStatic memberFrameReportedOccurs when a touch message is sent.

The FrameReported event is included in Windows Presentation Foundation (WPF) to support compatibility with Silverlight. If you do not have to ensure compatibility with Silverlight, use the touch events, such as TouchDown and TouchMove, on UIElement, UIElement3D, or ContentElement.

The FrameReported event does not use the same event model as other WPF input events, such as TouchDown and TouchMove. Instead of being exposed as an element-specific event that potentially routes through the object tree of a UI, the FrameReported event is a single event that is handled at the application level. Therefore, you cannot use the sender parameter of the event handler to determine what element is touched.

Use the TouchFrameEventArgs to get the TouchPoint values that are relevant to the touch event. From the TouchPoint, you can get the Position of the touch and determine whether the TouchAction was a Down, Move, or Up action. You can also use the TouchPoint to get the TouchDevice. From the TouchDevice, you can determine the device Id and get information about the element that is touched.

The following example enables you to create simple patterns on a Canvas by dragging two fingers across a touchscreen. Each touch is represented by a TouchDevice.The pattern is created by drawing a line between the touch points 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.

<Window x:Class="WpfTouchFrameSample.MainWindow"
        Title="MainWindow" Height="525" Width="525">
        <Canvas x:Name="canvas1"
                Width="500" Height="500"
                Background="Black" />     

The following code handles the FrameReported event. When a touch presses 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 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.

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

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft