私は次のものを持っています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
動的にバインドする必要があります。Text
TextBlock
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);
私は何をしなければなりませんか?ありがとう。