I would like to create an ItemTemplate for a ComboBox programmatically (like the topic says).
At the moment I have an ItemTemplate in XAML:
<Style x:Key="ComboBox_EntityCreation_GroupSelect_Style" TargetType="{x:Type ComboBox}">
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} {1} Mitglied(er)">
<Binding Path="Name"/>
<Binding Path="MemberCount"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
As a result of my hatred for XAML I would like to get the result without XAML.
Is it possible to do this?
I have just converted this on the fly. Please check whether it works.
You can assign a DataTemplate to its VisualTree using FrameworkElementFactory.