(This seems to be a quite outdated reply.)
There are valid uses of ContentPresenter
everywhere. My primary use of it is to dispatch the view by the runtime type of the content.
Let me explain: imagine that you have a property of type Animal
in your VM, so you'd like to display it somewhere in your UI. If you have a single UI for any kind of Animal
, you can put it into a UserControl
, and use a construct like
<AnimalControl DataContext="{Binding Animal}"/>
However imagine that you've got a bunch of different animals, say, Toad
s, Human
s and Unicorn
s. So you'd like to differentiate between them (maybe you've developed several UserControl
s for them). You do it in the following way:
<ContentPresenter Content="{Binding Animal}"/>
In order for the correct view to be used, you need the following DataTemplate
s to be in scope:
<DataTemplate TargetType="{x:Type vm:Unicorn}">
<UnicornControl/>
</DataTemplate>
etc. Usually people get such a functionality using TemplateSelector
/ContentTemplateSelector
, but this way is valid, too, and seems to be simpler (you can shuffle template scopes with custom styles, a la CSS).