In Silverlight 5, we can use a new feature called “implicit data templates”. An “implicit data template” is a data template that will be used based on the type of the bound object instead of a “manual definition”. That is, we can define data templates and tell them what type they render, and then let the system figure out what template to use as it binds objects.
This sounds really brilliant… Let’s try it out!
Let’s start by creating ridiculously simple example that resembles the samples you normally see when people talk about this.
Firs of all, I need a couple of classes to bind to, so I will create a car class and a motorcycle class, both inheriting from a Vehicle class. They will be very simple…something like this
public class Vehicle
{
public string Make { get; set; }
public string Model { get; set; }
public double EngineSize { get; set; }
}
public class Car : Vehicle
{
}
public class Motorcycle : Vehicle
{
}
Ok…so as you can see, they are VERY simple…but they will do for this sample… The inheritance and stuff like that is completely irrelevant, but it felt wrong writing 2 identical classes…
Next, in my MainPage.xaml, I will add a ListBox to display a list of Vehicles…
<Grid x:Name="LayoutRoot" Background="White">
<ListBox x:Name="VehicleList"></ListBox>
</Grid>
…and then in the code behind, I create a list of vehicles and set it as the ItemsSource of the ListBox
public MainPage()
{
InitializeComponent();
var vehicles = new List<Vehicle>()
{
new Car() { Make = "Saab", Model = "9-5", EngineSize = 2.3 },
new Motorcycle() { Make = "Ducati", Model = "Monster", EngineSize = 750 },
new Car() { Make = "Volvo", Model = "XC60", EngineSize = 2.0 },
new Motorcycle() { Make = "KTM", Model = "Super Duke", EngineSize = 850 }
};
VehicleList.ItemsSource = vehicles;
}
No, I’m no cars or motorcycles expert, but I know enough to get around… I do for example know that cars measure their engine size in liters, and motorcycles in cubic centimeters. But the important thing here is obviously not the data but the display, which currently looks like shit…

Ok…so that was expected with the styling, or lack of styling, that I currently have…
So, let’s add some styling. And I will start by adding it the way we currently do
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Rectangle Fill="Green" Visibility="{Binding Converter={StaticResource VisibilityConverter}, ConverterParameter=Motorcycle}" />
<Rectangle Fill="Purple" Visibility="{Binding Converter={StaticResource VisibilityConverter}, ConverterParameter=Car}" />
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock>
<Run Text="{Binding Make}" /><Run Text=" " />
<Run Text="{Binding Model}" /><Run Text=" " />
<Run Text="{Binding EngineSize}" /><Run Text=" " />
</TextBlock>
<TextBlock Text="cc" Visibility="{Binding Converter={StaticResource VisibilityConverter}, ConverterParameter=Motorcycle}" />
<TextBlock Text="liter" Visibility="{Binding Converter={StaticResource VisibilityConverter}, ConverterParameter=Car}" />
</StackPanel>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
As you can see, I show off the vehicles with some minor changes to the template. Basically I show a green background for a motorcycle and a purple one for a car. I also make sure that the engine size is displayed using the right way, liter vs cc.
In this case this is done using a converter that just checks name of the bound type to a passed in parameter and return Visible if it matches and Collapsed if it doesn’t.

Beautiful! Just as expected…
In Silverlight 5 however, we can skip the converter and use implicit data templates, which means that we can define 2 different data templates and just define what types they are responsible for rendering. It looks like this
<ListBox x:Name="VehicleList">
<ListBox.Resources>
<DataTemplate DataType="entities:Car">
<Grid>
<Rectangle Fill="Purple" />
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock>
<Run Text="{Binding Make}" /><Run Text=" " />
<Run Text="{Binding Model}" /><Run Text=" " />
<Run Text="{Binding EngineSize}" /><Run Text=" " />
</TextBlock>
<TextBlock Text="liter" />
</StackPanel>
</StackPanel>
</Grid>
</DataTemplate>
<DataTemplate DataType="entities:Motorcycle">
<Grid>
<Rectangle Fill="Green" />
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock>
<Run Text="{Binding Make}" /><Run Text=" " />
<Run Text="{Binding Model}" /><Run Text=" " />
<Run Text="{Binding EngineSize}" /><Run Text=" " />
</TextBlock>
<TextBlock Text="cc" />
</StackPanel>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.Resources>
As you can see, I have removed the ItemTemplate and put 2 DataTemplates in the Resources collection instead. I have also given them a DataType attribute telling them what type they are supposed to render.
The control will then automatically figure everything out, and display it exactly like the previous template did. The cool thing is that it uses the Resources dictionary, which gives us the ability to “inherit” templates across different controls and so on…
This seems like a really neat feature, so why is the title questioning it? Well, I find that couples the view to whatever it is rendering. Well, to be honest, it is just me feeling this way…we are literally writing the class names of the types to render in the DataType property for the DataTemplate. How much more can we couple it?
In the real world, I would probably use MVVM for my application. And the whole idea behind MVVM is to decouple the view from the model/viewmodel, making it flexible and allowing me to use the same view for several different VMs and vice versa. Using implicit data templates, we are explicitly telling the view that types we are using, which in most cases means telling the view the exact VM type that will be used. Basically the opposite of everything we should be doing.
There must be other ways to do this and get this “automagical” template thing going. No, it probably won’t be as magical, but the magic is unfortunately very limiting… I might get back to this topic… 
So, my conclusion is that this works nicely if you are building something without MVVM, but I find that it is probably a bit too much coupling for my taste… But please, do correct me if I am wrong!