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.
In the XAML I have added a ContentControl and bound the Content property to the Person DependencyProperty.
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.
Implicit DataTemplates can be added at Application level or locally in controls as done in the sample above.
You can download the sample here.
One Response to “Silverlight 5 – Implicit DataTemplates”