4

ItemTemplateSelector is applied to collections of objects - ItemsControl for example.

Is there the same functionality for single items controls? I want to choose a data template taking in consideration a value inside an object. I can do this for lists but not single items.

edit:

In another screen I have this implementation:

<ItemsControl ItemsSource="{Binding Path...} ItemTemplateSelector={...}

The thing is, now I only have one item and still want to have a itemtemplateselector ...

edit 2:

The question that arises can also be: How can I put just one item in the ItemsSource?

Louro
  • 1,413
  • 4
  • 21
  • 27
  • Wondering if you can just bind Template and use a converter to supply the template...have you tried that? – Charleh Jul 10 '12 at 09:05
  • gives us some code for your different objects. nevertheless i dont like templateselectors - most time all can achieved with datatemplate and datatype. – blindmeis Jul 10 '12 at 09:11
  • @Charleh: didnt remember that, it maybe a little hack but I think it would work. blindmeis: I dont like to expose my business objects in the view so I dont use datatypes :( – Louro Jul 10 '12 at 09:17
  • @blindmeis some code and more explaination added – Louro Jul 10 '12 at 09:36

1 Answers1

7

Seems that what you are looking for is the ContentTemplateSelector of a ContentControl.

Clemens
  • 123,504
  • 12
  • 155
  • 268