pchajer
pchajer

Reputation: 1584

WPF Routed Events and Command in MVVM

After reading Routed Events and Commands, a question comes in my mind when we write code using MVVM

Routed Events is used in dependency property and Routed Commands is used in View Model.

Is my understanding correct?

Upvotes: 1

Views: 2283

Answers (1)

Rick Sladkey
Rick Sladkey

Reputation: 34250

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.

Upvotes: 1

Related Questions