我刚接触过WPF Prism,我在网上看到了很多关于Prism的文章,我发现所有的示例代码都使用windows应用程序作为shell,所以我有一个问题,我可以让UserControl作为shell吗?如果不是为什么?
发布于 2017-08-09 10:11:53
shell应该是一个窗口,因为WPF应用程序总是有一个顶级窗口(除非作为XBAP托管在broswer中),但是可以将窗口的Content设置为引导程序的InitializeShell()方法中的用户控件:
protected override DependencyObject CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void InitializeShell()
{
Application.Current.MainWindow.Content = new UserControl();
Application.Current.MainWindow.Show();
}UserControl必须托管在窗口或页面中。这不是最高级别的控制。
发布于 2020-09-15 13:49:32
https://stackoverflow.com/questions/45583460
复制相似问题