.net - What key to use if adding a data template to the resources of a control -


I have a data template that is defined in the XAML file. XAM root not is a resource dictionary but there is a data template. Now I want to add this data template to control resources. Unfortunately, I do not know which key to use.

  myControl.Resources.Add (?????, dataTemplate);  

Although I use the data template datatap property (i.e. the type that I want to templates) WPF Resource Lookup Engine does not use my data template.

Anyone? Thanks!

Edit: I know that the type of goal will be to move with the styles, but with the data templates it seems that it is different ...

Edit:

Answer: OK, I did a little debugging. Here is the correct code

  myControl.Resources.Add (New DataTemplateKey (typeof (...), datamapplet);  

Use the form for which datatemplate is designed: myControl Add Resources. (TheType, Datamapplet);


Comments