我有ListView
的标准GridView
。现在我希望GridView
中的一列成为列表中该行的从1开始的索引,如下所示:
| # | First name | Last name |
| 1 | John | Smith |
| 2 | Anne | Anderson |
我该怎么做?
答案 0 :(得分:1)
忘了回答这个,因为列是静态的,你可以创建一个ItemSource绑定到数组或任何持有项目。
<GridView ItemSource="{Binding ArrayName}"
ItemTemplate="{StaticResource gridViewTemplates}"
Name="Whatever" ...>
</GridView>
现在我们必须设置模板
<DataTemplate x:Key="gridViewTemplates">
<TextBlock Row="{Binding RowNumber}" Column="0" Name="Id"
Text={"Binding Id"} />
</DataTemplate>
请对您最适合的事情进行更改。
this tutorial上的更多信息。