This project has moved. For the latest updates, please go here.

Import a ViewModel

Nov 17, 2011 at 7:23 PM

I'm new to MEF and to Jounce and am trying to understand something.

In your documentation, you describe how to reference another viewmodel like so:

   public void OnImportsSatisfied()
   {
      _otherViewModel = Router.ResolveViewModel("OtherViewModel");
   }

That makes sense.

But the question I have is this: Why not just use [Import], like this:

[Import]

public OtherViewModel OVM {get; set;}

Is there a reason to prefer one over the other?

Also, if you use the [Import] method, what tag would you use to import a viewmodel that was exported with this tag: [ExportAsViewModel("OtherViewModel")]?

I can't import the view model when I use [Import("OtherViewModel")].  (However, I was able to get it to work by using a tag of just [Export("OtherViewModel")])

Thanks