good day. How can I programmatically copy datatemplate from application resources and paste it into my own usercontrol?

  • Ctrl-C + Ctrl-V tried? - VladD
  • you apparently did not understand. On the basis of the data, it is necessary to programmatically copy the already prepared template from the resources into your user control. the data is different every time - Arthur
  • Why copy it, connect resources and use. By name or data type. - Monk
  • And the data of the same type for which UserControl? - VladD

1 answer 1

I would venture to suggest that your data comes from a binding and is in DataContext . For this case it just works.

 <ContentPresenter Content="{Binding тут-ваша-привязка}"/> 

Ensure that resources from the ResourceDictionary connected so that the DataTemplate is visible.

  • Comments are not intended for extended discussion; conversation moved to chat . - Nick Volynkin