Article about aggregating WPF commands

I just published yet another article about WPF this weekend on CodeProject.  This one is about my new CommandGroup class, which allows you to create a “composite command.”  The article explains the problem that this class solves, but also explains that the solution has uses outside of just that one problem.  If you are interested in checking it out, here is the link:

http://www.codeproject.com/KB/WPF/commandgroup.aspx

6 Responses to Article about aggregating WPF commands

  1. Joe says:

    I like how you think outside of the box on some of these issues and it is interesting to read. However, you could also acquire the same results using the already built in CommandParameter property, could you not?

  2. Josh Smith says:

    Joe,

    Thanks for the feedback.

    I don’t see how CommandParameter could be used to accomplish what CommandGroup offers.

    Josh

  3. Joe says:

    Hi Josh,

    We actually do this sort of thing all of the time. Binding elements directly into the command parameter. Our execute callbacks do exactly what your execute on your ICommand interface implementation accomplishes. Since CommandParameter is an object, you can also pass in multiple elements through a value converter as well, as an array for instance. Simple example: Command=”ApplicationCommands.Save” CommandParameter=”{Binding ElementName=BindingTextBox}”. It’s pretty much the same code flow after that.

    -Joe

  4. Josh Smith says:

    Joe,

    I see what you mean. The exact task accomplished by the CommandGroup demo program is certainly a cat that can be skinned in more than one way. But keep in mind that CommandGroup can be used in ways completely unrelated to the usage seen in the demo app. That aside, in my opinion, the CommandGroup approach is “cleaner” than the CommandParameter approach. I like having things be explicit, instead of using things like the Tag or CommandParameter property. To each his own. 🙂

    Josh

  5. Joe says:

    Hi Josh,

    As I cetainly agree that to each his own. I was just inferring that indeed there is more than one way to “skin a cat” which is one of the reasons WPF is so great. I think what people should really take out of the article is that they should think outside of the box when it comes to WPF because there is so much there to play around with. As I am sure we can both agree that someone else can probably come up with a completely different solution to what we have both discussed, and in the end that is great.

    -Joe

  6. Josh Smith says:

    Great point, Joe. I completely agree!😀

    Having options is (almost) always a good thing.

    Josh

%d bloggers like this: