WPF Attached Events vs Non-Attached Events

The difference is mostly syntactic, both delegate references are being handled by WPF’s EventManager but what the attached events give you is the ability to declare generic functionality without needing to bloat all your classes’ implementation.

In the case of a normal routed event, the class provides the interface to be able to at some point respond to an event by calling the event handler. But all WPF needs to know is if it is an object of derived from a given type and if a handler was registered. This means that we can make simpler class hierarchies and also supports the Open-Closed Principle (Open to Extension, Closed to Modification). This way a programmer can define a new behavior that several classes should have but does not need to modify the original classes.

See also Attached Properties

Leave a Comment