I'm building a Silverlight control and I'm trying to set up bindings for the Header and Body ContentControls through their respective DataTemplates. I'm not sure why, but this does not work (silently fails). My only guess is that it is because the DataTemplates are StaticResources. Can anyone offer advice? The control has the following default template:
<Style TargetType="local:LayoutItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:LayoutItem">
<StackPanel>
<StackPanel.Resources>
<DataTemplate x:Key="DefaultHeaderTemplate">
<StackPanel>
<TextBlock Text="{Binding HeaderText}" FontSize="15"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="DefaultBodyTemplate">
<StackPanel>
<TextBlock Text="{Binding BodyText}" FontSize="12"/>
</StackPanel>
</DataTemplate>
</StackPanel.Resources>
<ContentControl x:Name="Header"
ContentTemplate="{StaticResource DefaultHeaderTemplate}" />
<ContentControl x:Name="Body"
ContentTemplate="{StaticResource DefaultBodyTemplate}" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
Thanks!
Update
Actually, the following code does not work either, so my assumption about the StaticResources might be wrong.
<ContentControl x:Name="Header">
<ContentControl.ContentTemplate>
<DataTemplate x:Key="DefaultHeaderTemplate">
<StackPanel>
<TextBlock Text="{Binding HeaderText}" FontSize="15" />
</StackPanel>
</DataTemplate>
</ContentControl.ContentTemplate>
</ContentControl>