【发布时间】:2014-03-06 02:41:00
【问题描述】:
我希望以下内容可以让我获得单元格中的列索引:
<DataGridTemplateColumn Header="Rec. No." Width="100" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Source={RelativeSource AncestorType=DataGridCell}, Path=Column.DisplayIndex}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
但它没有。谁能告诉我这里出了什么问题?
我实际上是在寻找行索引(在我的网格中需要一个记录号列),但由于 DataGridRow 显然没有“索引”类型的属性,我尝试首先为列做索引,有DisplayIndex。但即使是这个也行不通。
【问题讨论】:
标签: .net wpf xaml binding datagrid