2011-01-08 2 views
2

저는 WP7을 처음 접했고 분명히 뭔가 빠졌습니다. 아래의 코드에서는 사각형을 만들고 터치했을 때 그 색상을 토글합니다. 문제는 내가 동시에 두 개의 직사각형을 만질 때 하나만 이벤트를 얻는다는 것입니다. 나는 마우스 이벤트를 사용하고 있기 때문에 이것을 가정한다고 가정하지만 터치 이벤트가 표시되지 않습니다. 올바른 방향으로 어떤 포인터가 크게 감사하겠습니다. 뒤에Windows Phone 7의 UI 요소에서 동시 발생을 감지하는 방법

관련 XAML

 <Grid x:Name="LayoutRoot" Background="Transparent"> 
     <toolkit:WrapPanel x:Name="RectWrapPanel" Height="768" Width="480"/> 
    </Grid> 

코드 :

namespace colortouch 
{ 
    public partial class MainPage : PhoneApplicationPage 
    { 
     SolidColorBrush blueBrush = new SolidColorBrush() { Color = Colors.Blue }; 
     SolidColorBrush redBrush = new SolidColorBrush() { Color = Colors.Red }; 
     SolidColorBrush blackBrush = new SolidColorBrush() { Color = Colors.Black }; 

     // Constructor 
     public MainPage() 
     { 
      InitializeComponent(); 

      for (int i = 0; i < 126; i++) 
      { 
       Rectangle rect = new Rectangle(); 
       rect.Height = 50; 
       rect.Width = 50; 

       rect.Stroke = blackBrush; 
       rect.Fill = blueBrush; 

       //rect.MouseLeftButtonDown += new MouseButtonEventHandler(rect_MouseLeftButtonDown); 
       rect.MouseEnter += new MouseEventHandler(rect_MouseEnter); 
       Button b = new Button(); 

       RectWrapPanel.Children.Add(rect); 
      } 
     } 

     void rect_MouseEnter(object sender, MouseEventArgs e) 
     { 
      Rectangle rect = sender as Rectangle; 

      if (rect.Fill == blueBrush) 
       rect.Fill = redBrush; 
      else 
       rect.Fill = blueBrush; 
     } 
    } 
} 

답변

관련 문제