Windows Phone 8上的多点触控按钮

时间:2014-04-26 12:11:03

标签: c# xaml windows-phone-8 multi-touch

我在Windows Phone 8应用程序中使用了一堆矩形形状,我需要支持多点触控,因此可以同时点击其中一些。我没有对此进行任何额外处理,因为我认为Windows Phone 8应用程序默认支持多点触控。

所有内容都是用C#和XAML编写的。当我尝试同时按下两个矩形时,点击事件永远不会被击中。

感谢你对此有任何想法。

瓷砖的XAML:

<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>

所有三个的点按处理程序:

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);
                }
            }
        }

1 个答案:

答案 0 :(得分:0)

我不得不想出自己的MultiTouch逻辑。意思是我正在使用触摸检测 - 我跟踪每帧中触摸的内容。当元素获得免费触摸时,我决定采取什么行动。