Jeremy Likness' Blog

MVVM with MEF in Silverlight Video Tutorial Part 2: Plugins and Metadata

In the first part of this series, I demonstrated a very simple project that used MVVM (Model-View-ViewModel) along with the Managed Extensibility Framework to produce a simple screen that toggled between a square and a circle.

In this next video, I am re-designing the original project. This video starts with the original solution, but then I rework the code, using metadata, to turn the shapes into plugins. I duplicate the original effort with the new design (using a combobox instead of a checkbox because now we can support 1 ... n plugins) and then show how easy it is to add a new plugin with the architecture.

Download the source code for this project.

Here is the final application:

Download the source code for this project.

Jeremy Likness

On Mar 9 2010 9:21 AMBy jlikness MEFWith 4 Comments

Comments (4)

  1. Richard Thurgood

    GREAT tutorial Jeremy! Your step-by-step approach makes it simple for those of us who are just diving into MEF/Silverlight.

    Keep up the great work!!!

  2. Thank you, Jeremy for your first MVVM / MEF tutorial and this as well. I am having difficulty making the leap however to a data-bound model versus your "self-contained" example. I used your project as a baseline and have tried to extend the custom user control to go get data from a service. The ContentControl is loaded correctly, the data is returned from the service and the ViewModel value is set, but no display. Do you have an example that might assist?

    Thanks again for clear, useful vidz!

  3. So I'd have to know more of your code to better understand what's going on, but typically I would hide the service behind an IService. For example, if I'm getting a list of widgets, I'd use:

    void GetWidgets(Action> callback);

    Then I'd have a method to pass in callback that moves the list to the ObservableCollection on my model. If you are using straight WCF services wired up by default then they'll execute on the UI thread, otherwise you'll need to use the dispatcher to marshall them when they return.

Leave a Comment