WPF Routed COmmands.
Can some one explain me what is Routed Commands in WPF, with suitable example. When to use routed command and when to use ICommand.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manikandan MurugesanRank #300 · 8.4K reputationPosted Jun 17, 2017, 5:52 AM EDT
Pradeep YadavRank #478 · 5.2K reputationPosted Jun 19, 2017, 7:24 AM EDT
Routed command can route (bubble/ tunnel) through the element hierarchy. Routed Command implements ICommand interface. It allows attaching input gestures like Mouse input and Keyboard shortcuts .Its source can be decoupled from target. WPF provides more than 100 built in command. These commands can be integrated to WPF controls which has command property like button, MenuItem, etc. EditingCommand, ComponentCommand, NavigationCommand, AplicationCommand are some of the classes which organise and expose built in commands.
You can create customized Routed commands by implementing ICommand.
You need to create static instance of type RoutedCommand. Then you need to implement _CanExecute and _Executed for the same.