storyboard to animate regions in the shell

Jul 5, 2008 at 1:56 PM
Edited Jul 9, 2008 at 10:40 AM
Hi,
I'm trying to  activate a storyboard that animates Shell regions as a response to an event raised by a module. I want to use a single storyboard to animate more than one region to insure syncronization. 
I have placed my storyboard in the Shell. But I know I should not refrence the shell from  the modules. 
Any recommendations on how this should be done? Where should I place my storyboard? and how to activate it? Is it proper to have the shell refrence the container and then subscribe to an event?

Thanx
Jul 11, 2008 at 6:10 PM
Edited Jul 11, 2008 at 6:31 PM
samykabu, there are several apporaches you can use to do this. One simple approach is to look to use the EventAggregator in the Composite Application Library. With it you can have decoupled communication between modules and the shell or components in the shell. The only thing needing to be shared will be the event definition itself.. Instead of actually having the logic for manipulating the storyboard itself, I would put it either in the Presenter/Presentation Model for the view where the storyboard lives or in a controller which can access that view. The view subscribes to the EventAggregator event and listens for notifications. The module will then grab that event and fire it when it needs to notify the view.

First you'll need to define an event class which represents your new event

    public class MyEvent : CompositeWpfEvent<string>{}

Then the Presenter / PM which wants to listen needs to grab a hold of it in it's initialization. That view will need the IEventAggregator to be injected in it's constructor.

    public class MyPresenter(IMyView view, IEventAggregator eventAggregator)

    public void Initialize()
    {
       eventAggregator.GetEvent<MyEvent>().Subscribe(HandleEvent, ThreadOption.UIThread);
    }

    public void HandleEvent(MyArgs args)
    {
       ...
    }


Finally the module will fire the event for wherever it chooses

    EventAggregator.GetEvent<MyEvent>().Publish(value);

There are also several other apporaches, you can find out more about the pros and cons of some of them here.

Regards
Glenn