How are markup extensions useful? They provide a hook to perform functionality that would be impossible or overly complicated using traditional approaches such as attached properties or behaviors. One popular use of markup extensions is to provide access to static classes that otherwise are not available in XAML. A common reason to do that would be to access a service locator – for example, to generate your view model.
To illustrate how to create your own, I decided to use the Managed Extensibility Framework as an example. It is often challenging to insert classes that are managed by MEF into XAML because they require a step known as “composition” to wire dependencies. With a custom markup extension, however, that limitation goes away because the extension can perform the composition call!
Read Full Post: Creating a Markup Extension for MEF with Silverlight 5
@JeremyLikness – Jeremy Likness is a Project Manager and Senior Consultant for Wintellect, a nationally recognized consulting, training and debugging firm dedicated to helping companies build better software, faster through a concentration on .NET and Windows technologies.