user1462071
user1462071

Reputation: 13

Prism4: Creating catalog from xaml CreateFromXaml doesn't compile

I'm developing with Silverlight 4 and Prism 4.

I'm also using Unity as my injection container.

I'm trying to create the module catalog from xaml, but I get this error "IModuleCatalog does not contain a definition of CreateFromXaml...".

My code snippet is:

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));
        }
    }
}

What could I be missing here?

Upvotes: 1

Views: 693

Answers (1)

shawn1874
shawn1874

Reputation: 1435

The reason that you need to add the full path to the ModuleCatalog type is that there is a ModuleCatalog property within the Bootstrapper base class that UnityBootstrapper inherits. If you don't qualify the name, you are essentially calling an accessor on a property which returns IModuleCatalog. The interface definition does not include this function.

Upvotes: 1

Related Questions