WPF Prism:创建外壳的问题 [英] WPF Prism: Problem with creating a Shell
问题描述
我刚刚开始学习Prism并尝试在测试WPF应用程序中将其与MEF一起使用.
基于"WPF动手实验:Prism入门
Prism4 文档中的库" 示例,在一个测试WPF项目中,我将 MainWindow 类重命名为 Shell .
我的Bootstrapper类具有以下代码(同样基于Lab示例):
I just started learning Prism and trying to use it with MEF in a test WPF application.
Based on "WPF Hands-On Lab: Get Started with the Prism
Library" example in the Prism4 documentation, in a test WPF project I renamed MainWindow class to Shell.
My Bootstrapper class has the following code (also based on the Lab example):
class Bootstrapper : MefBootstrapper
{
protected override DependencyObject CreateShell()
{
return new Shell();
}
protected override void InitializeShell()
{
Application.Current.MainWindow = (Shell)this.Shell;
Application.Current.MainWindow.Show();
}
...
App.xaml.cs代码:
App.xaml.cs code:
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Bootstrapper bootstrapper = new Bootstrapper();
bootstrapper.Run();
}
}
当我尝试运行该应用程序而没有在其中导出任何模块时,出现错误消息:
无法找到资源'mainwindow.xaml'."
When I try to run the app even without exporting any module in it, I get an error:
"Cannot locate resource 'mainwindow.xaml'."
我在做什么错了?
推荐答案
重命名您的类时,mainwindow.xaml是否重命名为shell.xaml?
When you renamed your class did mainwindow.xaml get renamed to shell.xaml?
但是代码/配置仍指向原始名称.
But the code/config is still pointing to the original name.
这篇关于WPF Prism:创建外壳的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!