Silverlight 5 – Custom Markup Extensions

20 Apr

A Markup Extension is a class that decides at runtime how to set a property’s value. Markup extensions allow code to be run at XAML parse time for both properties and event handlers.

In Silverlight 4 we got some different Markup Extensions:

  • Binding
    Text=”{Binding Path=FirstName, Mode=TwoWay}”
  • StaticResource
    Foreground=”{StaticResource BlueSolidColor}”
  • TemplateBinding
    VerticalAlignment=”{TemplateBinding VerticalContentAlignment}”
  • NullExtension
  • RelativeSource
    DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"

With Silverlight 5 we get Custom Markup Extensions allowing us to write more specific and complex Markup Extensions.

Jeff Prosise’s have written a good sample here and Jeremy Likness have written about getting creating a custom markup extension that uses MEF to satisfy imports on object instances declared in XAML here.

by xamlgeek

One Response to “Silverlight 5 – Custom Markup Extensions”


  1. Silverlight 5 beta « xamlgeek - April 20, 2011

    […] Custom Markup Extensions […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: