#580 – Events in WPF are Routed

In Windows Forms, controls make use of traditional .NET events to notify a user that something interesting happened in the control.  When a user clicks on a button, the corresponding Button object will raise a Click event.  You can then define an event handler that does something as a response to the click.

In WPF, events are routed, meaning that the originating control will raise the event but the event will also be passed on to other controls and they will also raise the event.  More specifically, events are passed up (bubbled) or down (tunneled) the logical and visual trees in WPF.

For example, if a StackPanel contains a Button and the user clicks on the button, the Button object will raise a Click event and then the containing StackPanel will also raise a Click event.  The Click event is a bubbling eventso it bubbles up the logical tree.


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

4 Responses to #580 – Events in WPF are Routed

  1. Pingback: #581 – An Example of a Routed Event « 2,000 Things You Should Know About WPF

  2. Pingback: Dew Drop – June 15, 2012 (#1,346) | Alvin Ashcraft's Morning Dew

  3. Pingback: #586 – Bubbling and Tunneling Events Are Typically Paired « 2,000 Things You Should Know About WPF

  4. Pingback: #1,073 – Attached Events | 2,000 Things You Should Know About WPF

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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: