Arbitrary Header content for each row in WPF datagrid

Posted by tk on Stack Overflow See other posts from Stack Overflow or by tk
Published on 2010-05-21T14:27:57Z Indexed on 2010/05/21 14:30 UTC
Read the original article Hit count: 264

Filed under:
|
|

I'm trying to put row header text based on a converter function of the index of the row. I found a way to bind to the datagridrow like below, but i can't find how to get the row index of the datagridrow object.

<DataTemplate x:Key="MyRowHeaderTemplate" DataType="DataRowView">
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Margin="1,0,1,0" Padding="1,0,1,0"
               Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}, Path=Item}"/>
</DataTemplate>

How can i get the row index and use my converter function to set the row header text?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about wpf