【发布时间】:2012-09-21 13:12:11
【问题描述】:
我有以下DataTemplate:
<DataTemplate x:Key="ButtonTemplate">
<Button Click="Cell_Click">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<TextBlock x:Name="TBlock" />
</ControlTemplate>
</Button.Template>
</Button>
</DataTemplate>
我将这个DataTemplate 用作GridViewColumn.CellTemplate,但是当我添加新列时,我必须动态绑定TextBlock 的Text 属性:
GridViewColumn column = new GridViewColumn();
column.CellTemplate = Resources["ButtonTemplate"] as DataTemplate;
// How to get the TBlock (TextBlock) of CellTemplate and bind its property here?
MyGridView.Columns.Add(column);
我该怎么办?谢谢。
【问题讨论】:
标签: c# wpf gridview binding datatemplate