3

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?

Sangram Nandkhile
  • 17,634
  • 19
  • 82
  • 116
  • What kind of parameters? Your `DataTemplate` is empty at the moment. Also, `DataTemplate` determines, how a data object (model or view model) is presented in GUI. I don't understand, why your `DataType` is set to a control type. Maybe `ControlTemplate` is what you're after? See: http://msdn.microsoft.com/en-us/library/ms745683.aspx#styling_controltemplates – pbalaga Sep 01 '13 at 08:09

2 Answers2

1

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.

Athari
  • 33,702
  • 16
  • 105
  • 146
0

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

how to add user controls as listbox items

Thanks

Community
  • 1
  • 1
Nitin
  • 18,344
  • 2
  • 36
  • 53