views:

25

answers:

2

I have declared a DataTemplate in Window.Resources; I don't intend to use it inside an ItemsControl, but rather just use it as a user control. How do I put it on a form?

+1  A: 

If you're using MVVM, and want to display the DataTemplate in response to a property on your ViewModel, you can use:

<ContentPresenter Content="{Binding Data}"/>

Where Data is a property of the type you registered the DataTemplate with.

Groky
+3  A: 

You can put a ContentControl into your user control, and set its ContentTemplate to your DataTemplate.

<ContentControl ContentTemplate="{StaticResource keyOfDataTemplate}"/>
Andy
Andy I hope my edits are ok with you
Rob Fonseca-Ensor