In C# I'm creating a series of ListBoxes each of which require an ItemTemplate, however I cannot figure out the correct way to assign the the template to the ListBox. On the XAML side, the template reads:
<DataTemplate x:Key="ProgramTemplate"><TextBlock Text="{Binding XPath=name}"/></DataTemplate>
And in XAML I can assign the template with:
ItemTemplate="{StaticResource ProgramTemplate}"
However I need to do this in C# rather than XAML. Can someone help provide a solution?
The closest I have been able to get is with:
listBox1.ItemTemplate = StaticResourceExtension("ProgramTemplate");