Prism4:从xaml创建目录CreateFromXaml无法编译

时间:2012-06-21 13:23:19

标签: silverlight-4.0 unity-container prism-4

我正在使用Silverlight 4和Prism 4进行开发。

我也使用Unity作为我的注射容器。

我正在尝试从xaml创建模块目录,但是我收到此错误“ IModuleCatalog不包含CreateFromXaml的定义 ...”。

我的代码段是:

using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Prism.UnityExtensions;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.MefExtensions;

namespace MyModularityProject {
    public class MyBootStrapper : UnityBootstrapper {
        protected override DependencyObject CreateShell() {
            return ServiceLocator.Current.GetInstance<Shell>();
        }

        protected override void InitializeShell() {
            base.InitializeShell();
            Application.Current.RootVisual = (UIElement)Shell;
        }

        protected override IModuleCatalog CreateModuleCatalog() {
            // This is the isntruction that doesn't compile
            return ModuleCatalog.CreateFromXaml(new 
                Uri("/MyProject.Silverlight;component/ModulesCatalog.xaml",
                    UriKind.Relative));
        }
    }
}

我可以在这里找到什么?

1 个答案:

答案 0 :(得分:1)

您需要添加ModuleCatalog类型的完整路径的原因是UnityBootstrapper继承的Bootstrapper基类中存在ModuleCatalog属性。如果您没有限定名称,那么您实际上是在返回IModuleCatalog的属性上调用访问器。接口定义不包括此功能。

相关问题