Ask a questionAsk a question
 

QuestionStill can't import an exported property?

  • Monday, October 12, 2009 5:42 PMsaxisa Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Very odd.  Everything else works.  My MainView gets called by App.xaml.cs, and is part of a composed batch.  MainView imports MainViewModel, which in turn does an ImportMany on other models, such as DatabaseLoginModel.  So in MainViewModel I have this:

    [ImportMany("CentralModel")]
    private Lazy<ViewModelBase, ICentralViewMetaData>[] views = null;

    views, then, does indeed contain the models I want, which get displayed just fine.

    But this property, in MainViewModel:
    [Export("SetActiveView")]
    public string SetActiveView
    {
        set { _av = value; }
        get { return _av; }
    }

    Is still not being properly imported in DatabaseViewModel:
    [Import("SetActiveView")]
    public string SetActiveView { get; set; }

    Is it possibly because of the Lazy ImportMany of DatabseViewModel?

    What else could it be?  As far as I can tell, all the right viewmodels are being created by MEF correctly, but I still cant inject a property.

All Replies

  • Monday, October 12, 2009 8:31 PMsaxisa Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Found the problem, kind of.

    I think there is something happening under the hood, where automatic properties are not composed against non-auto properties.  Changing the property in DatabaseViewModel to a non-auto property resulted in correct mapping.

    I ended up changing this to a method anyways.