I had to come up with my own MultiTouch logic. Meaning that I was using touch detection - and I keep track of what has been touched in each frame. When the element gets touch free I decide what action to take.
Multi-touch buttons on Windows Phone 8
-
09-07-2023 - |
Вопрос
I am using bunch of rectangle shapes in my Windows Phone 8 app and I need to support multi-touch so a few of them can be tapped at one time. I am not doing any extra handling on this as I thought that multi-touch is supported by default in Windows Phone 8 apps.
Everything is written in C# and XAML. When I try to press two rectangles at the same time the tap event never gets hit on either of them.
Thank you for any thoughts on this.
XAML of tiles:
<Rectangle x:Name="tile11" HorizontalAlignment="Left" Height="103" Margin="10,22,0,0" VerticalAlignment="Top" Width="103" Tap="TileClickHandler" Hold="TileHoldHandler" MouseLeftButtonDown="tile11_MouseLeftButtonDown" MouseLeftButtonUp="tile11_MouseLeftButtonUp">
<Rectangle.Fill>
<ImageBrush Stretch="Fill" ImageSource="/Assets/Tiles/DEFAULT.png"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle x:Name="tile12" HorizontalAlignment="Left" Height="103" Margin="120,22,0,0" VerticalAlignment="Top" Width="103" Tap="TileClickHandler" Hold="TileHoldHandler" MouseLeftButtonDown="tile11_MouseLeftButtonDown" MouseLeftButtonUp="tile11_MouseLeftButtonUp">
<Rectangle.Fill>
<ImageBrush Stretch="Fill" ImageSource="/Assets/Tiles/DEFAULT.png"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle x:Name="tile14" HorizontalAlignment="Left" Height="103" Margin="340,22,0,0" VerticalAlignment="Top" Width="103" Tap="TileClickHandler" Hold="TileHoldHandler" MouseLeftButtonDown="tile11_MouseLeftButtonDown" MouseLeftButtonUp="tile11_MouseLeftButtonUp">
<Rectangle.Fill>
<ImageBrush Stretch="Fill" ImageSource="/Assets/Tiles/DEFAULT.png"/>
</Rectangle.Fill>
</Rectangle>
One tap handler for all three:
private void TileClickHandler(object sender, System.Windows.Input.GestureEventArgs e)
{
if (IsRecordingActive)
{
StopRecording();
IsRecordingActive = false;
ManageTileState(ActiveRecordingTile, Constants.TileStates.HAS_SOUND);
}
else
{
System.Windows.Shapes.Rectangle tile = (System.Windows.Shapes.Rectangle)sender;
if (DoesTileHaveSound(tile))
{
Thread soundThread = new Thread(new ParameterizedThreadStart(PlaySound));
soundThread.Start(tile.Name);
}
}
}
Решение
Не связан с StackOverflow