I am just going through the WPF concepts I came across these routed events, dependency properties and attached events.
What are the concepts behind them and why are they called instead of .NET ordinary methods?
The definition is followed by an example of a WPF node with three buttons. The single routed event is listening for three buttons. If you try to write the same code using ordinary events, you'll have to use three separated events, one event by button.
This means that, instead of defining multiple events on every control in a same child, you have to define a routed event at the parent level, which will be raised by every concerned child.
Further, you may want to read Routed Events on WPFTutorial.net which uses a more precise terminology than my answer, and which also explains why routed events usually appear as pair.
Think it as a way to simplify your code (and especially the ability to use the code), since you can use a dependency property as an ordinary one.
Further, you may want to read a more complete article on Switch On The Code article, which also explains why it makes sense that a
This is particularly useful when the object which raises the event is independent from the actual WPF tree. One of the examples given by the same documentation is the mouse events, when those events are not related to the WPF element which, like in case of
Further, you may want to read Attached Events By Example, which explains that "the class defining the event is often neither the user of the event (whoever consumes it by adding a handler on it) nor the source of the event (whatever code raises it).", and gives much more details about attached events and their difference with routed events.