Louro
Louro

Reputation: 1453

WPF ItemTemplateSelector to single item

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?

Upvotes: 4

Views: 3630

Answers (1)

Clemens
Clemens

Reputation: 128013

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

Upvotes: 7

Related Questions