我已經在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