Take the 2-minute tour ×

This is a related to SO Question 3222456 ....

I'm creating my own UserControl with a few images and TextBlock's on it, nothing else. I'd like to fire an event when the whole UserControl is clicked. My problem (or misunderstanding) is that in WPF there only seem to be MouseUp events that I can hook into, no MouseClick.

So what's the best practice? All the examples I can find act as if a mouseUp in WPF is equivalent to a click event but that's not right. What if the user did a mouseDown in one part of the screen, held the mouse until it was over my control, and then released the mouse. That's not a click of my control even though it fires a MouseUp event.

So how do I get a true MouseClick event for my UserControl?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

One very easy way would be to put your entire content into a button with an almost empty template and respond to the Button's OnClick event.

This would look like


<UserControl ...>
  <Grid> ... </Grid>


<UserControl ...>
   <Button OnClick="YourEventHandler">
      <Grid> ... </Grid>
        <ControlTemplate x:Key="BlankButtonTemplate" TargetType="{x:Type ButtonBase}">
           <Border Background="#00000000">
             <ContentPresenter Margin="{TemplateBinding Padding}"
                               HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                               VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
share|improve this answer
Thanks @Jens, this looks promising, I'll give that a try. Do you use this technique frequently? I see how it would work but it seems like a kludge. –  sisdog Oct 25 '12 at 15:07
I do use it quite frequently. You can create a ControlTemplate resource with the template in it and just use <Button Template="{StaticResource BlankButtonTemplate}" /> then. This clears things up quite a bit. –  Jens Oct 26 '12 at 6:38

Why not just use MouseDown?

Put the event in the User Control and simply do this:

 private void MyControl_MouseDown(object sender, MouseButtonEventArgs e)
     if (e.ChangedButton == MouseButton.Left)
share|improve this answer

Your Answer


