Silverlight 5 has added many new useful features. If you have not read about Silverlight 5’s new features then read Silverlight 5: What’s New.

Implicit Templates is one of the new features included in Silverlight 5. Implicit Templates can be said to be data templates associated with a particular data type. These templates will be applied to all template-driven controls which are trying to display the specified data type.

For example, If you have two classes Manager and Employee both derived from the Person class. Now you would like to display the list of people in your company with different styling for each type of person. this is where Implicit Templates make your life easy.
Just specify two Data Templates for each of the two classes i.e. Manager and Employee.

<ListBox x:Name=”PeopleList”>


<DataTemplate DataType=”local:Manager”>

<StackPanel Orientation=”Horizontal”>

<TextBlock Text=”{Binding Name}” FontWeight=”Bold” />
<TextBlock Text=”(Manager)”  FontStyle=”Italic” Margin=”5,0,0,0″/>



<DataTemplate DataType=”local:Employee”>

<StackPanel Orientation=”Horizontal”>

<TextBlock Text=”{Binding Name}” />
<TextBlock Text=”{Binding ManagerName, StringFormat=’Managed by: {0}’}” FontStyle=”Italic” Margin=”5,0,0,0″ Foreground=”Gray” />





This will display some thing like this:

Implicit Templates does allow you to easily specific unique characteristics of an object in your data template.

Another example many people use for Implicit Templates  is Twitter. See this example from Pete Brown

In his post, Pete Brown describes Implicit Templates in more detail. If you would prefer a video, Pete Brown demonstrates Implicit DataTemplates.

Related Links


Share your thoughts

Please log in using one of these methods to post your comment: 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