How to dynamically skin a application using Prism 2

Topics: Prism v2 - WPF 3.5
Aug 12, 2009 at 8:38 PM


I would like to skin dynamically my application. What  i mean is that the user can click on a menuitem and the color of the application change.

I did this very well in my application and when i move on Prism i dont have no idea to do that. Here is my approach.

To spread my resources in all modules, i put them in the shell (application resource). The application has a menu that is come from a separate module. The user click on a menuitem to select his color.

I would like to use IEventAggregator to publish this event from the menu module and subscribe to this same event in the shell in order to change my resource. But there is no way to access the IEventAggregator from the shell.

Does anybody has a nice solution to do that?


Aug 13, 2009 at 6:05 PM

Hi blochaou, 

Using the EventAggregator is a good idea for the scenario you described.
To access the IEventAggregator from the Shell you can do it using constructor DI. You can do it directly in the shell view or use a presenter:

public Shell(IEventAggregator eventAggregator)

For this approach to work, you will have to delegate the creation of the shell in the bootstrapper to the DI container. This approach is used in the Event Aggregator Quickstart: 

protected override DependencyObject CreateShell()
    Shell shell = Container.Resolve<Shell>();

    return shell;



Hope it helps! 

Matias Bonaventura

Aug 13, 2009 at 7:07 PM

Thanks Matiasbonaventura

It works very well. 

Aug 14, 2009 at 1:11 AM

For those that may want to know "how" to Skin in PRISM (Desktop) I blog on the topic