Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

6. MVVM > Connecting a View to a ViewModel using MEF

Connecting a View to a ViewModel using MEF

Applies to Silverlight 4 and 5

In the previous recipe, we used the ViewModelLocator to connect our Views to our ViewModels. Another approach you can take is to use the Managed Extensibility Framework (MEF) to do this for you.

One of the advantages of this approach is that besides relaying the responsibility of providing the ViewModels to MEF, you can now use multiple ViewModel instances of the same type without having to create a ViewModelLocator property for each, for example: you can use this approach if you don't know in advance how many instances you'll need (amongst some other advantages, which will be described in this recipe).

In this recipe, you'll learn how to use MEF for tying your Views to your ViewModels.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint