-1

我正在为 Windows Phone 8 编写一个 Wordsearch 游戏。

屏幕 http://kepfeltoltes.hu/130804/j_t_k_www.kepfeltoltes.hu_.png

这是游戏窗口,那些矩形是自己的用户控件。这是矩形的定义,在 XAML 中:

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Rectangle x:Name="Kitoltoszin" Stroke="White" Width="100" Height="100" StrokeThickness="3" RadiusX="10" RadiusY="10" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Rectangle.Fill>
                <SolidColorBrush Color="Gray"/>                
            </Rectangle.Fill>
        </Rectangle>
        <TextBlock x:Name="Betu" Width="70" Height="70" 
                   FontWeight="Bold" FontSize="42" Foreground="White" 
                   HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" />
    </Grid>

我想要做的是检测哪个矩形被触摸并对其进行处理(例如将其背景设为蓝色)。有没有一种简单的方法可以做到这一点?以及如何刷新 WP8 中的页面?

4

1 回答 1

1

因此,您需要使用 的MouseLeftButtonUp事件Rectangle,因此您将添加标记:

MouseLeftButtonUp="Kitoltoszin_MouseLeftButtonUp"

然后在代码隐藏中添加处理程序:

private void Kitoltoszin_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    // do what you want here
}
于 2013-08-19T20:23:57.503 回答