1

I am building an application for the Samsung SUR40 in MS Surface 2.0.

I cant let the LostTouchCapture work anymore.

This is my XAML code:

<Rectangle 
   x:Name="ActiveArea" 
   Fill="Transparent" 
   TouchDown="OnTouchDown" 
   TouchMove="OnTouchMove" 
   LostTouchCapture="OnLostTouchCapture" 
/>

A piece of my C# code:

private void OnLostTouchCapture(object sender, TouchEventArgs args)
{
   Console.WriteLine("Hello World");
}

The TouchDown and TouchMove do work. But I have a problem with the LostTouchCapture. The function was working but now its broke and I dont know why.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Ron van der Heijden
  • 14,803
  • 7
  • 58
  • 82

3 Answers3

2

I didn't fix it really, but I use the TouchLeave="OnTouchLeave" instead.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Ron van der Heijden
  • 14,803
  • 7
  • 58
  • 82
  • I don't think this is the best solution, since it's constantly firing, but it seems to be the only one that works so far. I noticed that if you remove the `TouchDown` event, the `TouchUp` is fired (you should always add the `IsManipulationEnable = true` to the desired UI element), but if you put both, the `TouchUp` stops being fired. Maybe it has to do with handling the `TouchDown` event, however I already marked it as `false` and still no luck. – Schrödinger's Box Oct 23 '13 at 11:14
0

You were using the wrong event anyways, if you want to get the event when the touch leaves the rectangle, TouchLeave is the event you are looking for, LostTouchCapture event is when you are tracking the TouchDevice on an UIElement (for DragDrop or Manipulation) using Capture on the TouchDevice.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Imran Shaik
  • 305
  • 2
  • 6
0

You can use:

http://msdn.microsoft.com/de-de/library/system.windows.uielement.loststyluscapture.aspx instead, it worked for me.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Andreas
  • 3,843
  • 3
  • 40
  • 53