我已经在XAML中定义了DataTemplate,但是我需要将它更改为在运行时定义,因为它的绑定是动态的。如何在运行时创建DataTemplate?
<UserControl.Resources>
<DataTemplate x:Key="myCellTemplate">
<TextBlock Text="{Binding Description}" Margin="4"/>
</DataTemplate>
</UserControl.Resources>
有什么方法可以在代码隐藏中定义它吗? 谢谢。
[在代码中创建Silverlight DataTemplate]的可能重复(http://stackoverflow.com/questions/59451/creating-a-silverlight-datatemplate-in-code) – 2014-07-29 03:59:57