2013-08-19 28 views
-1

我寫一個單詞搜索遊戲到Windows Phone 8。捕捉如果自己的用戶控件被點擊或不

screen 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中的頁面?

回答

1

所以,你需要消耗MouseLeftButtonUp事件Rectangle的,所以你會添加標記:

MouseLeftButtonUp="Kitoltoszin_MouseLeftButtonUp" 

,然後在後臺代碼中添加處理程序:

private void Kitoltoszin_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) 
{ 
    // do what you want here 
} 
+0

這一點。背景=新的SolidColorBrush(Colors.Blue);並沒有任何反應 – fzl

+0

@Daniel,使用下來的顏色和默認顏色 –