70-511 · Question #103
You are developing a Windows Presentation Foundation (WPF) application. A user control responds to a click event. The click event handler sets the Handled property to true. You need to ensure that a…
The correct answer is A. Programmatically add an event handler to the parent control and set the HandledEventsToo. For most common handler scenarios, marking an event as handled by setting Handled to true will "stop" routing for either a tunneling route or a bubbling route, and also for any event that is handled at a point in the route by a class handler. However, there is a…
Question
You are developing a Windows Presentation Foundation (WPF) application. A user control responds to a click event. The click event handler sets the Handled property to true. You need to ensure that a parent control responds to the event after the user control's handler executes. What should you do?
Options
- AProgrammatically add an event handler to the parent control and set the HandledEventsToo
- BAdd a tunneling routed event handler to the parent control.
- CAdd a bubbling routed event handler to the parent control.
- DProgrammatically add an event handler to the parent control and set the HandledEventsToo
How the community answered
(28 responses)- A82% (23)
- B11% (3)
- C4% (1)
- D4% (1)
Explanation
For most common handler scenarios, marking an event as handled by setting Handled to true will "stop" routing for either a tunneling route or a bubbling route, and also for any event that is handled at a point in the route by a class handler. However, there is a "handledEventsToo" mechanism whereby listeners can still run handlers in response to routed events where Handled is true in the event data. In other words, the event route is not truly stopped by marking the event data as handled. You can only use the handledEventsToo mechanism in code, or in an EventSetter:
Topics
Community Discussion
No community discussion yet for this question.