Let's say I have a collection of objects of different classes. Each class has its UserControl DataTemplated in a resource file.
Now I want to use ItemsControl to display the collection, but I want an Border or Expander around each item.
I would expect something like this to work:
<ItemsControl ItemsSource="{Binding MyObjects}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Black" BorderThickness="3">
<ContentPresenter/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
But the ContentPresenter seems to pick ItemTemplate, because I get a stack overflow.
How do I get each Item's DataTemplate inside the ItemTemplate?