Provides data for the Touch.FrameReported event.
Assembly: PresentationCore (in PresentationCore.dll)
Thetype exposes the following members.
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetPrimaryTouchPoint||Returns the current touch point of the primary touch device relative to the specified element.|
|GetTouchPoints||Returns a collection that contains the current touch point for each active 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.)|
|SuspendMousePromotionUntilTouchUp||This member is not implemented.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
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.
Use the 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 handles the FrameReported event and accesses the touch data in the . 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 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.
This example is part of a larger example that is available in the Touch class overview.
Class MainWindow ' Variables for tracking the position of two points. Private pt1, pt2 As Point Public Sub New() InitializeComponent() AddHandler Touch.FrameReported, AddressOf Touch_FrameReported End Sub Private Sub Touch_FrameReported(ByVal sender As System.Object, ByVal e As System.Windows.Input.TouchFrameEventArgs) If (canvas1 IsNot Nothing) Then For Each _touchPoint In e.GetTouchPoints(Me.canvas1) If _touchPoint.Action = TouchAction.Down Then ' Clear the canvas and capture the touch to it. canvas1.Children.Clear() _touchPoint.TouchDevice.Capture(canvas1) ElseIf _touchPoint.Action = TouchAction.Move Then ' This is the first (primary) touch point. Just record its position. If _touchPoint.TouchDevice.Id = e.GetPrimaryTouchPoint(Me.canvas1).TouchDevice.Id Then pt1.X = _touchPoint.Position.X pt1.Y = _touchPoint.Position.Y ' This is not the first touch point; draw a line from the first point to this one. ElseIf _touchPoint.TouchDevice.Id <> e.GetPrimaryTouchPoint(Me.canvas1).TouchDevice.Id Then pt2.X = _touchPoint.Position.X pt2.Y = _touchPoint.Position.Y Dim _line As New Line() _line.Stroke = New RadialGradientBrush(Colors.White, Colors.Black) _line.X1 = pt1.X _line.X2 = pt2.X _line.Y1 = pt1.Y _line.Y2 = pt2.Y _line.StrokeThickness = 2 Me.canvas1.Children.Add(_line) End If ElseIf _touchPoint.Action = TouchAction.Up Then ' If this touch is captured to the canvas, release it. If (_touchPoint.TouchDevice.Captured Is canvas1) Then canvas1.ReleaseTouchCapture(_touchPoint.TouchDevice) End If End If Next End If End Sub End Class
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2