user2736867
user2736867

Reputation: 31

Using a Usercontrol inside Datatemplate

I have a datatemplate with following code

<DataTemplate x:Key="TplFullImages" 
    DataType="{x:Type cControl:FullVisableImageControl}">
</DataTemplate>

cControl:FullVisableImageControl is my usercontrol

However I still need the Usercontrol to have the parameters when it initializes. How can I achieve this and what other options do I have?

Upvotes: 3

Views: 597

Answers (2)

Athari
Athari

Reputation: 34293

What you probably want to do is this:

<DataTemplate x:Key="TplFullImages">
    <cControl:FullVisableImageControl}" Property="Value"/>
</DataTemplate>

DataTemplate.DataType is used when a property from your model is of type set in DataType, and you bind one of the controls to this property. Considering you've specified the x:Key attribute, this is not what you want to do.

For examples of using DataTemplate.DataType see MSDN: DataTemplate.DataType Property.

Upvotes: 1

Nitin Purohit
Nitin Purohit

Reputation: 18578

I have answered the similar one yesterday. Please check if it helps.

how to add user controls as listbox items

Thanks

Upvotes: 0

Related Questions