To date, the only supported NET3.5-NET4, SL4-SL5 assembly.

For work in design mode, you need add class:

    [MvvmApplication(1)]
    public class DesignApplication : MvvmDesignApplication
    {

        #region Overrides of MvvmDesignApplication

        /// <summary>
        /// Creating a main Ioc adapter for design mode.
        /// </summary>
        /// <returns/>
        protected override IocAdapterBase CreateDesignerContainer()
        {
            var mugenInjector = new MugenInjector();
            mugenInjector.Bind<string>().ToConstant("Hello design Ioc container");
            mugenInjector.Bind<IRepository>().ToConstant(new FakeRepository());
            return new MugenIocAdapter(mugenInjector);
        }

        #endregion
    }

The number in the attribute indicates the priority for loading class. If you have two classes that will be selected with the highest priority.

In the view must be added:

<Window x:Class="MugenMvvmDesignModeWpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Behaviors="clr-namespace:MugenMvvmToolkit.Behaviors;assembly=MugenMvvmToolkit" Title="MainWindow" Height="350" Width="525" 
        Behaviors:DesignViewBehavior.ViewName="MugenMvvmDesignModeWpf.MainWindow">

Write the full name of the class view. If for one view exist more than once view model use this syntax FULLVIEWCLASSNAME;FULLVIEWMODELCLASSNAME, example:

<Window x:Class="MugenMvvmDesignModeWpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Behaviors="clr-namespace:MugenMvvmToolkit.Behaviors;assembly=MugenMvvmToolkit" Title="MainWindow" Height="350" Width="525" 
        Behaviors:DesignViewBehavior.ViewName="MugenMvvmDesignModeWpf.MainWindow;MugenMvvmDesignModeWpf.MainWindowViewModel">

After this datacontext is equal to a given view model, and Ioc container will contain the value specified for the design mode.

Each view model supports property IsDesignMode, it indicate whether the control is in design mode (running under Blend or Visual Studio).

Example:

        public string UseProperty
        {
            get
            {
                if (IsDesignMode)
                    return "Property design mode";
                return "Property not design mode";
            }
        }

Last edited May 4, 2012 at 8:27 AM by VVS0205, version 6

Comments

No comments yet.