TriggerAction for multiple TargetControl

TriggerAction for multiple TargetControl

Old forum URL: forums.lhotka.net/forums/t/10115.aspx


Imker posted on Monday, February 28, 2011

I am taking my first steps here with TriggerAction and ViewModel in CSLA.

 

After creation of a TriggerAction and binding it to a button the following question pops up:

How do you organize your TriggerActions in the XAML? It seems like there will be a

whole bunch of TriggerAction for things like Save, AddNew.

And must I declare two separate TriggerAction to get a Save Button and a Save Menu Item?





RockfordLhotka replied on Tuesday, March 01, 2011

Yes, one TriggerAction listens to one event, from one UI control. So you need a different TriggerAction to listen to each UI event of each different UI control.

This isn't the only option out there, and if this approach disturbs you, one option is to evaluate some of the other options:

  1. Commanding
  2. Various commanding frameworks that make commanding more broadly useful
  3. Expression Blend SDK trigger event and behavior concepts
  4. Solutions provided with various UI and/or MVVM frameworks out there
  5. SL5 event binding (when SL5 comes out)

Basically, Microsoft didn't provide a comprehensive solution in the box - certainly not one that does everything we all want, and also works with the VS designer and with the Blend designer.

So everyone has had to create some solution of their own.

TriggerAction is the third solution I've come up with - after InvokeMethod and Execute. It isn't perfect, but it is (imo) better than the previous two attempts.

I really like the Blend SDK solution, except that attached properties aren't supported by the VS designer, so that solution forces you to type lots of XAML by hand...

Copyright (c) Marimer LLC