#661 – ButtonBase.Click Event vs. Mouse Click Events

Controls that derive from ButtonBase, like the standard Button, inherit a Click event that fires when user clicks on the button using the left mouse button.

Because ButtonBase inherits from UIElement, a Button will also have access to all of the mouse button events defined for UIElement.

Because the Button does something in response to button presses, it swallows the bubbling events (e.g. MouseLeftButtonDown and MouseDown).  You can still detect these lower level button press events by adding handlers for the tunneling events (e.g. PreviewMouseLeftButtonDown and PreviewMouseDown).  You can also request that your handlers are called even for already-handled events by specifying a handler in code and setting the handledEventsToo parameter to true.

For a left-click on a Button, you’ll normally see click-related events in the following order:

  • UIElement.PreviewMouseLeftButtonDown 
  • UIElement.PreviewMouseDown
  • UIElement.PreviewMouseLeftButtonUp
  • UIElement.PreviewMouseUp
  • ButtonBase.Click

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

2 Responses to #661 – ButtonBase.Click Event vs. Mouse Click Events

  1. Pingback: Dew Drop – October 4, 2012 (#1,415) | Alvin Ashcraft's Morning Dew

  2. Pingback: Wpf event not bubbling - oneuptime | oneuptime

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: