I have a DataTemplate
:
<DataTemplate x:Key="myTemplate">
...
</DataTemplate>
I want to use it as the ContentTemplate
of a ContentPresenter
:
<ContentPresenter Content="{Binding X}">
<ContentPresenter.ContentTemplate >
<!-- ????? what goes here ????-->
</ContentPresenter.ContentTemplate>
</ContentPresenter>
How can I use the predefined DataTemplate
in my ContentPresenter
?
Should be something like:
<ContentPresenter Content="{Binding X}" ContentTemplate="{StaticResource myTemplate}"/>
Although I wouldn't define a Template on a contentpresenter, I will select the correct template based on the type anyway.
You just need to reference the defined resource:
<ContentPresenter Content="{Binding X}" ContentTemplate="{StaticResource myTemplate}"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With