$title =

Silverlight 5 – Implicit DataTemplates

;

$content = [

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

];

$date =

;

$category =

;

$author =

;

$previous =

;