views:

251

answers:

1

I have a standard ListView with a GridView. Now I want one of the columns in the GridView to be the 1-based index of that line in the list, as such:

| # | First name | Last name |
| 1 | John       | Smith     |
| 2 | Anne       | Anderson  |

How do I do that?

+1  A: 

Forgot to answer this one, since the columns are static, you can create an ItemSource binding to the array or whatever is holding the items.

<GridView ItemSource="{Binding ArrayName}" 
          ItemTemplate="{StaticResource gridViewTemplates}" 
          Name="Whatever" ...>
</GridView>

And now we have to set the template

<DataTemplate x:Key="gridViewTemplates">
    <TextBlock Row="{Binding RowNumber}" Column="0" Name="Id" 
           Text={"Binding Id"} />
</DataTemplate>

Please do the changes to whatever suits you best.

More Info on this tutorial.

jpabluz