2012-08-15 74 views
0

我在XAML以下控件:Silverlight的帆布和Rectangle的鼠標事件

<Canvas Height="500" Width="500" Name="canPreview" VerticalAlignment="top" Grid.Row="1" Grid.RowSpan="3" MouseLeftButtonDown="canPreview_MouseLeftButtonDown" 
       MouseLeftButtonUp="canPreview_MouseLeftButtonUp" MouseLeave="canPreview_MouseLeave" MouseMove="canPreview_MouseMove" 
       Height="{Binding Path=ActualHeight, ElementName=imgPreview}" Width="{Binding Path=ActualWidth, ElementName=imgPreview}"> 
      <Rectangle Name="recSelection" StrokeThickness="2" Stroke="Black" Fill="Transparent" Opacity=".5" Height="100" Width="100" /> 
     </Canvas> 

,由於某種原因畫布事件僅當鼠標指針是矩形上方火災。任何想法是怎麼回事?

回答

2

設置畫布的背景顏色;你不能點擊沒有繪製的東西。

如果您不想看到畫布,則可以使用透明畫筆,它可以點擊。