Take the 2-minute tour ×  I am new to WPF and I am creating an
application which uses the TabControl. I am using a
DataTemplateSelector and my datasource is an object I created
from XML which have the properties "type" and "categoryID". I
select my data template based on the "type" which works fine but
I also need to create a tabitem for each categoryID during
runtime. My problem is currently it creates a new TabItem for
each object. How do I create a new tabitem based on the
categoryID and place the dataTemplate on that tab and if the tab
have already been created place the DataTemplate on that tab
instead of creating a new one.  Thanks in advance!!
share|improve this question You can use the ObservableCollection
class and binding to the ItemsSource property. Before adding an
item to the collection - check existance of this item in the
collection, and if it exists - don't add. –  vorrtex Apr 4 '11
at 13:51 add comment  1 Answer  up vote 0 down vote accepted  I
ended up using a CollectionViewSource with grou