the ItemTemplateSelector
will work but I think it is easier to create multiple DataTemplate
s in your resource section and then just giving each one a DataType
. This will automatically then use this DataTemplate
if the items generator detects the matching data type?
<DataTemplate DataType={x:Type local:ObjectA}>
...
</DataTemplate>
Also make sure that you have no x:Key
set for the DataTemplate
.
Read more about this approach here
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…