WPF Composite animate region in shell from module

Topics: Prism v2 - WPF 3.5
Jul 17, 2009 at 10:00 PM

So I've got a WPF app all setup. I have the shell and it loads the module.

I'd like to have the module animate a region inside the shell.xaml so I created an IShell interface in a seperate assembly.
shell.cs implements IShell and i inject the unity container into the modules view constructor like so

public Module1View(IUnityContainer container)
{
_container = container; 


then in some method in module1 i do this bit of code to get a reference to the shell and call one of the IShell methods.

 

var shell = _container.Resolve<IExtendableShell>();
                shell.showOverlay();

var shell = _container.Resolve<IShell>();
shell.showOverlay();

the showOverlay method is implemented in shell.cs and runs an animation BUT the animation never runs.

I've tried a number of different things UI wise such as changing a label or setting the visibility of an object but nothing updates the UI.
Intially I thought it must be a UI thread issue. So I added a dispatcher.BeginInvoke to update the UI but still nothing.

Does anyone have ANY idea whats going on here please?

Thanks
DML 

 

Jul 20, 2009 at 6:52 PM

Hi DML,

Assuming everything else is in place, it is possible that the particular animation you want to perform is not visible with a region (which are invisible by default). If this is not the scenario, you might check the following threads which deals with animation situations:

 

Another thing that might be causing the behavior you describe is if you are not registering the IShell as a singleton in the unity container (that would cause unity to create another instance of the shell which will never be shown).

Nevertheless, it's not a recommended practice to have the shell registered in the container. This tights your modules to the shell implementation (or interface) which is one of the problems prism tries to resolve. In your scenario, you could use the EventAggregator to let the Shell know how to manage the animation (start/stop), thus keeping things decoupled.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman