WPF UserControl Shell

Topics: Prism v4 - WPF 4
Aug 15, 2011 at 7:08 PM

Are there any examples using PRISM and Unity with a UserControl Shell instead of a Window shell?  Instead of typing everything out again here is the link to the original question:


Now I have been re-coding my original solution and I can get it into an infinite loop but it seems like there is no way to replace the following code in the bootstrapper when using a UserControl instead of a Window:

Application.Current.MainWindow = (Window)this.Shell;


As well a UserControl does not have the below code either:

public partial class App : Application
protected override void OnStartup(StartupEventArgs e)

     Bootstrapper bootstrapper = new Bootstrapper();


I have tried to take the bootstrapper code from above and place it in OnInitialized() but that results in an infinite loop.

I have not found a way to replace the MainWindow code either, there is no equivalent way to grab the UserControl from the bootstrapper.  I have tried passing the returned composed view out of the bootstrapper but this never results in anything happening.

I cannot find an example or any discussion regarding the proper way to use PRISM & Unity with a UserControl as the shell.

Why has nobody asked this question or shown an example of this?  Is it crazy to want to have composable user controls?  I would like to have a project that if I want to extend a control I make all I have to do is drop in another module, why is this not possible?

Aug 16, 2011 at 7:10 PM


We've created a sample application in which we have a regular window (which in your case would be the Palette control mentioned in the StackOverflow question) loaded in the WPF application as the start up uri, and then we host a Prism application inside of it, in which the Shell is just a UserControl that gets added to a StackPanel inside the hosting WPF view when the InitializeShell method is called.

You can find the sample in my skydrive account, under the PrismInsideHostingApplicationSample name.

I hope you find this helpful.

Guido Leandro Maliandi

Aug 23, 2011 at 8:45 PM

Thank you so much GuidoMaliandi! I downloaded the code and looked into it, I haven't got chance to try it, but I have a strong feeling that your solution will work for me.

Very smart idea. I will keep you posted the news after I apply it to my project

thanks again .