Silverlight 5 – Implicit DataTemplates

13 Apr

With Silverlight 4 came implicit styles. With Silverlight 5 comes implicit DataTemplates. Implicit DataTemplates allow DataTemplates for ContentPresenters to be selected based upon the type of its content.

In this sample I have created a Person entity containing a firstname and lastname property. For sample purpose only I have created a DependencyProperty of type Person that I can bind to in the XAML.

clip_image001

In the XAML I have added a ContentControl and bound the Content property to the Person DependencyProperty.

clip_image002

Using the new implicit DataTemplate feature I have created a DataTemplate based upon a type as a resource and the DataTemplate will be applied to the ContentControl.

clip_image003

Implicit DataTemplates can be added at Application level or locally in controls as done in the sample above.

You can download the sample here.

by xamlgeek
@thomasmartinsen

One Response to “Silverlight 5 – Implicit DataTemplates”

Trackbacks/Pingbacks

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

    […] Implicit DataTemplates […]

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: