After reading Routed Events and Commands, a question comes in my mind when we write code using MVVM
Routed Events is used in dependency propert开发者_C百科y and Routed Commands is used in View Model.
Is my understanding correct?
There are many ways to use routed events and routed commands but in the context of a typical MVVM pattern, routed events and routed commands are both part of the view, not the view-model. The reason is that the routing is inherently view-specific: bubbling and tunneling are controlled by and applicable to the visual tree which is part of the view. Once the routed event or routed command has found a target and that target has a data-context, then typically you can dispatch the routed event or routed command to a non-routed command in the view-model.
精彩评论