c# - 如何在没有 Application 类或不覆盖它的项目中正确使用 WPF Prism?
问题描述
可以在不覆盖 Application 类的情况下使用 Prism 吗?例如,在为 Visual Studio 开发扩展时。我还没有找到如何做到这一点的例子。
解决方案
答案就在这里。您可以使用相关代码,您仍然可以使用它们:
protected override Window CreateShell()
{
return null;
}
protected override void OnInitialized()
{
var shellWindow = Container.Resolve<ShellWindow>();
shellWindow.Show();
MainWindow = shellWindow.ParentOfType<Window>();
// there lines was not executed because of null Shell - so must duplicate here. Originally called from PrismApplicationBase.Initialize
RegionManager.SetRegionManager(MainWindow, Container.Resolve<IRegionManager>());
RegionManager.UpdateRegions();
InitializeModules();
base.OnInitialized();
}
推荐阅读
- android - 在 Recyclerview 中请求超过 5 个原生广告 - Admob
- awk - nf的多个选项用于识别不同位置awk中的重复项?
- mongodb - 根据在 Mongo Atlas 中创建的索引在前端创建 MongoDB 索引
- android - 状态展开的底片圆角
- ios - 为什么每台机器上的 iOS 模拟器快照都不同
- python - 是否可以使用 Python 来检测 Windows 的系统动态颜色模式(浅色或深色模式)?
- google-sheets - GoogleFinance - 调整后的股票收盘价
- r - dyn.load 中“networkD3”的 R/Docker 加载失败
- javascript - 当用户单击弹出卡上显示的特定卡时如何绑定数据?
- pandas - 如何通过查看另一列来填充一列中的 NaN 值