C# 捕获是否单击了自己的UserControl
我正在为WindowsPhone8编写一个文字搜索游戏 这是游戏窗口,这些矩形是自己的用户控件。 以下是矩形的定义(以XAML为单位):C# 捕获是否单击了自己的UserControl,c#,xaml,windows-phone-8,mouseevent,C#,Xaml,Windows Phone 8,Mouseevent,我正在为WindowsPhone8编写一个文字搜索游戏 这是游戏窗口,这些矩形是自己的用户控件。 以下是矩形的定义(以XAML为单位): <Grid x:Name="LayoutRoot" Background="Transparent"> <Rectangle x:Name="Kitoltoszin" Stroke="White" Width="100" Height="100" StrokeThickness="3" RadiusX="10" Ra
<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中刷新页面?因此您需要使用
矩形的事件,因此您将添加标记:
MouseLeftButtonUp="Kitoltoszin_MouseLeftButtonUp"
然后在代码隐藏中添加处理程序:
private void Kitoltoszin_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
// do what you want here
}
this.Background=新的SolidColorBrush(Colors.Blue);什么也没有happens@Daniel,使用向下表示该颜色,使用向上表示默认颜色