Mouse event on transparent background

I’m not sure why you get the results you get but it should work fine when the background is transparent (i.e. you explicitly set it to Brushes.Transparent, either through XAML or code). If it is null, WPF will not include it in hit testing, and thus it won’t be eligible for mouse events.

See e.g. http://msdn.microsoft.com/en-us/library/ms752097.aspx (A visual object that is transparent can also be hit test.)

Most likely you have another UIElement in your element tree that is capturing and handling the mouse event before your canvas sees it (i.e. by setting e.Handled to true)

Leave a Comment