templates – Silverlight/WPF – Can you have a different ItemTemplate depending on a base type of the item? – Education Career Blog

I am binding an ObservableCollection to a ListBox in Silverlight. The list can contain multiple Person or Vehicle objects which both derive from DomainObject. I would like to be able to have a different template for Person and Vehicle, but show them both in the same list. What is the best way to do this?

,

DataTemplateSelector is not available in silverlight but there are a few resources around showing examples of how to implement it in a control.

  1. Resource 1

  2. Resource 2

Leave a Comment