Handling routed events
Events are essentially notifications from an object to the outside world – a variation on the "observer" design pattern. Most of the time an object is told what to do via properties and methods. Events are its way of talking back to whoever is interested. The concept of events existed in .NET since its inception, but WPF has something to say about the way events are implemented. WPF introduces routed events, an enhanced infrastructure for raising and handling events, which we'll look at in this recipe.
Make sure Visual Studio is up and running.
How to do it...
We'll create a simple drawing application that uses routed events to handle user interaction:
- Create a new WPF Application named
CH01.SimpleDraw. This will ...