views:

34

answers:

1

I have a WPF user control that is dervied from UserControl class. MouseLeftButtonDown is not getting fired at all for the contol. I added event handler and also tried as follows. I guess it is handled somewhere else, how to debug and find where is it getting hanlded.. Any help is appreciated!

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
    base.OnMouseLeftButtonDown(e); 
} 
+1  A: 

Did you have the Background of the UserControl set to something? If not, try setting it to "Background=Transparent" and see if that works. If it doesn't work, can you post the XAML for your UserControl, as well as the XAML for its usage?

karmicpuppet
Thanks a lot, it worked like a magic. Can you please explain me the logic behind this?
Vin
It's all about WPF's HitTesting mechanism and its treatment of null brushes vs Transparent brushes. Here's a bit more information on this: http://agsmith.wordpress.com/2008/09/16/hit-testing-in-wpf/.
karmicpuppet