Silverlight: Creating a DataTemplate in XAML and Assigning It in Code?

Is it possible to create a DataTemplate in XAML and apply it to various controls through code?

If so, how do I bind the DataTemplate that I created in XAML?

+4
source share
1 answer

if you have

<UserControl.Resources> <DataTemplate x:Name="myTemplate" /> </UserControl.Resources> 

defined as a resource, you can refer to it as follows

 var myTemplate = (DataTemplate) Resources["myTemplate"]; 
+7
source

Source: https://habr.com/ru/post/1346458/


All Articles