DelegateCommand / CommandManager / WeakReference (lambada)

Topics: Prism v4 - WPF 4
Sep 5, 2010 at 6:03 PM

I have implemented MVVM with DelegateCommands. The commands shall listen to the CommandManager (UI changes).

The following thread does provide a working solution, but one has to change the Prism source code:

The follwing solution did not work in my case:

I implemented the lambada in the View, as well as in the ViewModel, but both did not work.

Does anyone have a suggestion, I am looking for a solution, where I do not need to change the Prism source code.

Would it be an option to have the first solution be implemented in the offical source code? ;-)

Thankx, Harry

Sep 7, 2010 at 5:07 PM


Sorry you have run into a snag in implementing your scenario.  By default, the Prism DelegateCommand does not subscribe to CommandManager.

This is by design.  We do this for two reasons.  First to make the WPF DelegateCommand work the same as the Silverlight DelegateCommand.  Second, the ViewModel's should know when a state change occurs that could effect if a command can execute or not; when this state change occurs the ViewModel would raise the CanExecuteChanged event.

If you want to use command manager in your WPF applications you have two options.  Either modify the DelegateCommand to meet your needs or use the WPF RelayCommand that does subscribe to command manager.

At this time, we won't be changing the Prism source code that we deliver.

Have a great day,



Sep 13, 2010 at 10:27 AM

Ran into exactly the same issue last week. I was using Josh Smith's RelayCommand, but have been switching over to prism so thought I might as well use the delegate command instead. Seems I need to stick to RelayCommand for my purposes, although this thread got me a bit worried...

Might be a good idea to point this out in the commanding example maybe?


Sep 13, 2010 at 6:36 PM


I've put in a request for a change to the docs to call this out.

Thank you for taking the time to report this to us.