I'm trying to host a content control within a data template.
Exactly similar to this: Putting a ContentControl *inside* a WPF DataTemplate?
I was successful in doing it via XAML. I'd like to do the same via code.
I created a style :
<Style x:Key="radioButtonAddtruefalse">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<StackPanel Orientation="Horizontal">
<RadioButton Content="True" IsChecked="{Binding Value}"></RadioButton>
<RadioButton Content="False" IsChecked="{Binding Value, Converter={StaticResource _invertedBooleanConverter}}"></RadioButton>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
and within a data template:
<DataTemplate>
<ContentControl Style="{StaticResource radioButtonAddtruefalse}"> /ContentControl>
</DataTemplate>
I tried doing this via code, but found nothing under DataTemplate that allows me to host a contentcontrol. Any suggestions?