I have to use this Command in a WPF application (i dont like it really but if i have to -> i have to ):
http://wpftutorial.net/DelegateCommand.html
But the main problem I have here is that I don t want to have in nearly every line of my code a call to the
RaiseCanExecuteChanged()
method. So what could I do to do that auto like RoutedUICommand does.
I have a lot of databindings and as example if Foo.FooProp != null Command can execute. But I want as less code as possible and so I would have to register events everywhere or update commands all over my application….
You could implement a form of
DelegateCommandwhich invokes the delegates added toCanExecuteChangedeverytime there is a change of possible consequence in the UI. This example usesCommandManager.RequerySuggested.I think I’ve seen an example like this before, perhaps in the MVVMLight toolkit?