DelegateCommand with no parameters

Topics: Prism v2 - Silverlight 3
Dec 1, 2009 at 4:44 PM


I see Delegatecommand is a generic class where the generic type is the type of parameter the command expects. How do I declare a DelegateCommand that doesn't expect any parameter types? I bet the answer is simple and staring me in the face ;-)

Thanks for your help


Dec 1, 2009 at 6:49 PM

DelegateCommand<object> is your friend :-)




Dec 1, 2009 at 7:04 PM
Edited Dec 1, 2009 at 7:04 PM


As you mentioned in this implementation of ICommand for Prism you aren't allowed to instantiate a DelegateCommand that doesn’t expect parameters. A workaround could be creating the instance of the DelegateCommand with the generic type as object and pass null as the parameter. Notice that as default behavior if you don’t pass any argument, you will receive a null as parameter.

On the other hand, if your application requires you to create a non-generic DelegateCommand, you may create a custom one by implementing the ICommand interface.<var></var>

I hope you can find this answer helpful.

Fernando Antivero