WPF: Routed events or regular events? -
In WPF, we routed the event when should they be used instead of regular events?
Rooted events are special behaviors, but this behavior is largely invisible if you use that element But want to handle an incident where he has been raised.
Where root events become powerful, if you use any of the suggested circumstances: define common operators on a common route, include your control, or your own Define custom control class.
Routing event listeners and rooted event sources do not need to share a common occurrence in their hierarchy. There can be an event listener or anyone for any routed event, therefore, you can set the entire available set of the entire working API set as a conceptual "interface", in which the different elements in the application exchange the event information, Can be given. The "interface" concept for these events is particularly applicable to input events.
Route events can also be used to communicate through the element tree, because for the event The event data is retained for each element in the route. One element can change something in the event data, and this change will be available to the next element in the path.
In addition to the routing aspect, there are two other reasons that any WPF event can be implemented as a routed event instead of a standard CLR event if you are implementing your own events , You may also consider these principles:
- Relevant events, such as some WPF styling and templateing features, are required for a routed event. This is an already related event identifier scenario
- Routing events support a class handling mechanism, so that the class can specify those static methods, which handle the routed events before reaching any registered instance handler. Can get opportunity. This control is very useful in design, because your class can implement event-driven class behavior, which can not be accidentally pressed by handling an event on an example.
Source:
Comments
Post a Comment