DelegateCommand with no arguments

Topics: Prism v2 - Silverlight 2, Prism v2 - Silverlight 3
Jul 31, 2009 at 5:06 PM

I want to create a command (DelegateCommand) that takes no arguments, but I cannot use the non-generic System.Action or leave the generic argument of DelegateCommand<T> empty. Is there a recommended solution or common practice in this situation? Or do I need to roll my own DelegateCommand class?

Jul 31, 2009 at 9:09 PM

In the absense of any other direction, I decided to create a delegate like this: DelegateCommand<object>. When I bind my control to the delegate I just don't specify a parameter so the argument ends up being null (not a problem since I just ignore it anyway).

Aug 2, 2009 at 7:46 PM

Hi, guy,

I list some code when you add a click event in Winform or ASP.NET:

private void button1_Click(object sender, EventArgs e)

this means button event doesnot pass any param to the event subscriber, I think it is the same as you use in the Prism. Given T as Object and pass null to it is a good idea.

This is my sample code to illustrate your puzzle:


Aug 3, 2009 at 7:42 AM

That's a good question with a good answer too, developmentally. :)