inherit constructor method

Nov 7, 2012 at 11:20 AM

Hi,

Best way inherit constructor method (public Setting set { get; set; }) in all ViewModels.

    [Export(typeof(IShell))]
    public class MainWindowViewModel : Conductor<object>.Collection.OneActive, IShell, IHandle<IShell>
    {
        readonly IWindowManager _windowManager;
        public Setting set { get; set; }
        public IShell Shell;

        [ImportingConstructor]
        public MainWindowViewModel(IWindowManager windowManager)
        {
            set = new Setting();
            Shell = this;
            this._windowManager = windowManager;
        }
    public interface IShell
    {
        Setting set { get; set; }
    }
Nov 7, 2012 at 12:05 PM

This is the correct way inherit constructor in all ViewModels IShell shell = MainWindowViewModel.Shell; OR IShell shell = Caliburn.Micro.IoC.Get<IShell>();

 

Nov 7, 2012 at 4:20 PM
Edited Nov 7, 2012 at 4:22 PM

[Import]
public IShell Shell{get;set;}

should theoretically work since it's already in the MEF container due to the export.

Nov 8, 2012 at 8:41 AM

Very Thanks for help me.