I have the following controls in xaml:
<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>
And for some reason the Canvas events only fire when the mouse pointer is above the rectangle. Any idea what is going on?
Set the background color of the Canvas; you can’t click something that isn’t drawn.
You can use the Transparent brush if you do not want to see the canvas, it will be clickable.