Friday, July 25, 2008

Josh Smith just published a great article about his solution to using RoutedCommands in WPF.

The problem he solves, has been solved by others before, however, I think this is a very lightweight succinct way of doing it.
Basically, when you set a command to a button, you will have to handle that logic (canExecute and Execute) in the codebehind of the view. Since you are (hopefully) using a MVC, MVP or MVVM approach, you would rather not go through the codebehind of the view, but directly route the commands to the appropriate viewmodel/controller.

He creates a relaying object that does just that. This results in a completely empty codebehind for the view, which is exactly what I like!

Good job Josh!

Friday, July 25, 2008 12:18:25 PM (Romance Standard Time, UTC+01:00)
Thanks a lot, Ruurd. I'm glad you like my approach. It was the most lightweight solution I could think of.

Josh
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):