1. When compiling the item items in The ListBox In the intent, the leftbuttondown or leftbuttonup events are not very effective and are easily triggered when sliding.
Therefore, to handle a touch event, if it is not slide, it is equivalent to clicking.
Private Point ? Startpoint;
Private Void Stackpanel_manipulationstarted ( Object Sender, manipulationstartedeventargs E)
{
Startpoint = E. manipulationorigin;
Base . Onmanipulationstarted (E );
}
Private Void Stackpanel_manipulationdelta ( Object Sender, manipulationdeltaeventargs E)
{
If (Startpoint. hasvalue)
{
If (Math. Abs (E. deltamanipulation. Translation. X) > 0 | Math. Abs (E. deltamanipulation. Translation. Y) > 0 )
{
This . Startpoint = Null ;
}
}
Base . Onmanipulationdelta (E );
}
Private Void Stackpanel_manipulationcompleted ( Object Sender, manipulationcompletedeventargs E)
{
If (Startpoint. hasvalue)
{
If (Math. Abs (E. totalmanipulation. Translation. X) = 0 && Math. Abs (E. totalmanipulation. Translation. Y) = 0 )
{
Frameworkelement touchedcontrol;
// Determine the control you click to make different judgments.
If(E. originalsourceIsTextblock)
{
}
Else If(E. originalsourceIsImage)
{
}
}
}
Base. Onmanipulationcompleted (E );
}
However, the problem above is that the specific control occupies a small proportion, so debugging on the device will find it difficult to click to enter, one trick here is to change its parent container, such as grid and stackpanel, to transparent!