![](/img/trans.png)
[英]WPF Prism, Set several dependency properties of a View (UserControl) from inside Shell
[英]WPF Prism set usercontrol as Shell
我是 WPF Prism 的新手,我看过很多关于 Prism 的在线文章,我发现所有示例代码都使用 Windows 应用程序作为外壳,所以我有一个问题,我可以让 UserControl 作为外壳吗? 如果不是为什么?
shell 应该是一个窗口,因为 WPF 应用程序总是有一个顶级窗口(除非作为 XBAP 托管在浏览器中),但是您可以在您的InitializeShell()
方法中将窗口的Content
设置为用户控件引导程序:
protected override DependencyObject CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void InitializeShell()
{
Application.Current.MainWindow.Content = new UserControl();
Application.Current.MainWindow.Show();
}
UserControl
必须托管在窗口或页面中。 它不是顶级控件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.