WPF Reflections

Dec 3 2007   11:40AM GMT

Attached events

Mark Shurmer Profile: MarkWPF

Firstly, what are they?

I say they are custom events that you can place into the tree in WPF to add extra functionality without subclassing controls.

The pure MSDN definition is:
“An attached event allows you to attach a handler for a particular event to some child element rather than to the parent that actually defines the event, even though neither the object potentially raising the event nor the destination handling instance define or otherwise ‘own’ that event in their namespace.”

However, you do have to read that quite a few times!
So I’ve broken it down into a few key elements:

  1. It is a normal WPF routed event
  2. They are custom events that mean you don’t have to subclass existing classes
  3. It is not a language event (with += & -= handlers in c#), you use AddHandler and RemoveHandler instead
  4. You can put them into attributes like standard system events

Hope that’s clear 🙂

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: