This project is read-only.

Let's look at how to setup NoMvvm.  

For this example, add a reference to NoMvvm and NoMvvm.MEF and add appropriate using statements.

In your App.xaml.cs, override OnStartup:

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            Runtime.Initialize().SetupMEF().Start("Main");
        }

Pass the name of your desired View/ViewModel to start with the application.

If you need to configure MEF, you can pass in a pre-configured CompositionContainer:

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            
            var catalog = new AggregateCatalog(
                new AssemblyCatalog(Assembly.GetExecutingAssembly()),
                new AssemblyCatalog(Assembly.Load("Your.Second.Assembly")));
            var container = new CompositionContainer(catalog);

            Runtime.Initialize().SetupMEF(container).Start("Main");
        }

By default, Initialize() uses a CompositionContainer with Assembly.GetEntryAssembly().  You will have to configure the container if you want to Import/Export from multiple assemblies.

Note: in Silverlight, NoMvvm has to call Assembly.GetCallingAssembly() as a substitute--it is not ideal but better than nothing.

Last edited Aug 24, 2011 at 4:28 AM by jonathanpeppers, version 10

Comments

No comments yet.