Composite commands should be generic

Topics: Prism v2 - Silverlight 4, Prism v4 - Silverlight 4
Mar 2, 2011 at 2:39 PM

After troubleshooting my 100th error today related to composite commands I had a realization.


They should be strongly typed.


Instead of MyComposite

Should be MyComposite<string> or whatever type you pick for the generic

Mar 2, 2011 at 3:14 PM


In Prism v2, you can only use DelegateCommands with a generic parameter.

However, as of Prism v4 there is both a generic overload and a non-generic overload of the DelegateCommand class. To illustrate this, here's a fragment from the DelegateCommand class inside the Prism.Silverlight project:


 /// <summary>
    /// An <see cref="ICommand"/> whose delegates do not take any parameters for <see cref="Execute"/> and <see cref="CanExecute"/>.
    /// </summary>
    /// <seealso cref="DelegateCommandBase"/>
    /// <seealso cref="DelegateCommand{T}"/>
    public class DelegateCommand : DelegateCommandBase

I hope you find this helpful.

Guido Leandro Maliandi