Workshop: Getting Started with MEF
Let's look at a very simple scenario in which MEF can be used to “inject” an instance of a class into another class, without the need to explicitly “new up” the class instance. We'll make the class known to MEF by “exporting” it, and “import” it into the view's code-behind class so that it can use it.
- Create a new project using the Silverlight Application project template, named
Chapter14Sample
. - Add a reference to the following MEF assemblies:
System.ComponentModel.Composition.dll
System.ComponentModel.Composition.Initialization.dll
- Add a new class to the project, named
PersonPart.cs
, containing the following ...
Get Pro Business Applications with Silverlight 5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.