Prism V2: Hosting Shell in WPF/WinForm Application
I am trying to make Shell as UserControl in WPF Composite applic开发者_运维百科ation. I Started by modifying the Quickstart app: "Quickstarts\UI Composition\ViewDiscovery". I made "UIComposition.Desktop.csproj" a UserControl class library with Shell.xaml as UserControl. Created another WPFApplication to host the Shell. Added the following code in App.xaml.cs:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Bootstrapper bootStrapper = new Bootstrapper();
bootStrapper.Run();
// Get ShellContainer from IOC
IUnityContainer container = bootStrapper.Container;
var shellElement = container.Resolve<Shell>();
ShellContainer win = new ShellContainer();
// Add the ShellContainer UserControl to the main window
win.mygrid.Children.Add(shellElement);
win.Show();
}
The form shows up with the shell but when I click on the employee it doesn't show the details view. Please help!!! If any body has tried this.
Thanks & Regards, Vishal.
You might try overriding the CreateShell method of the UnityBootstrapper, rather than using this OnStartup method. I'm not 100% that this is your issue, but it's something to try.
Your OnStartup method would then be:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Bootstrapper bootStrapper = new Bootstrapper();
bootStrapper.Run();
}
And here is the CreateContainer method:
protected override DependencyObject CreateShell()
{
var shellElement = Container.Resolve<Shell>();
var shellContainer = new ShellContainer();
shellContainer.mygrid.Children.Add(shellElement);
shellContainer.Show();
return shellContainer;
}
This is just a shot in the dark here. I really don't know what the problem is, but the 100% startup method solution doesn't seem right to me.
精彩评论