Custom Markup Extensions in Silverlight 5: Part 1


In this article we are going to learn about the Custom Markup Extensions in Silverlight 5 .

Created a new project SLCustomMarkup . Make sure that the Targeted Silverlight Version is Silverlight 5 .


CMESil1.gif

Create a class say FirstCME

CMESil2.gif

Lets start typing in the code . I implement the interface IMarkupExtension<T> here .

CMESil3.gif


CMESil4.gif


CMESil5.gif

CMESil6.gif

CMESil7.gif


Lets have a look at how the Interface ImarkupExtension<T> looks:

CMESil8.gif


CMESil9.gif

Lets now add a TextBlock and bind the text of it to FirstCME Extension which we had created .

CMESil10.gif

The Silverlight parser creates a instance of FirstCME and assigns the value of the property to the Text of the TextBlock .

Now we are done . Lets give it a run :

CMESil11.gif

Up Next
    Ebook Download
    View all
    Learn
    View all