Take the 2-minute tour ×

I'm struggling with an issue that is driving me crazy.

Here is my XAML code (simplified) :

            <StackPanel Orientation="Horizontal">
               <StackPanel Orientation="Vertical">
                     <Button Name="theButton" Click="theButton_Click"></Button>
                     <ComboBox Name="theCombo" SelectionChanged="theCombo_SelectionChanged"></ComboBox>

In the constructor of that UserControl :

AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(UserControl_MouseDown), true);

I need to capture mouse clicks for my own UserControl (I have to draw a selection rectangle with the mouse on top of it). So I use AddHandler(), and I indicate "true" so that I can hook the MouseLeftButtonDownEvent even if it has been handled by my Button "theButton" (because when a button is clicked, it marks the event Handled property as true as MSDN says)

When I click inside my UserControl, my function UserControl_MouseDown is normally called. But when I click on my Button, the associated handler("theButton_Click") is never called. Same thing for the SelectionChanged event of my ComboBox : its handler is never called.

I used a tool called Snoop to see the event routing, and it seems to be normal : my button catches the MouseDown, then sets to True its Handled property. But the code never reaches the handler.

If I unhook the event for my UserControl, it's OK. I tried with PreviewMouseDown for the Button. It runs, but I can't use this for my ComboBox

Do you have any clue to solve that issue and make my UserControl and my Button and ComboBox call their respective handlers ?

Thanks for your help

edit: code of my UserControl's event handler

private void UserControl_MouseDown(object sender, MouseButtonEventArgs e)
            if (e.ChangedButton == MouseButton.Left && !_isMoving)
                _isLeftMouseButtonDownOnWindow = true;
                _origMouseDownPoint = e.GetPosition(this);
                e.Handled = true;
share|improve this question
MSDN warns about this. What do you actually do in the UserControl's event handler? How do you even distinguish between a click that should just run the button's Click event vs one that should start drawing the rectangle? –  Hans Passant Nov 12 '13 at 18:28
@HansPassant : I have edited my question with my UserControl's handler. I distinguish both cases with a boolean (_isMoving) Can you give me the link of the MSDN relative to this ? –  Harkonnen Nov 13 '13 at 9:09

2 Answers 2

I don't know why it's Handled even though you set it with true for handled events

but you can just catch it before the button :

 AddHandler(PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(UserControl_MouseDown), true);
share|improve this answer
up vote 0 down vote accepted

Problem solved after copy/paste of my handler's code... by removing this line :


That was so obvious... My bad

share|improve this answer

Your Answer


