ItemIndex Property
See Also  Example
Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > RowSelector Class : ItemIndex Property

Gets the index of the RowSelector's associated data item.

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property ItemIndex As Integer
C# 
public int ItemIndex {get;}

Return Value

A zero-based value representing the index of the RowSelector's associated data item.

Example

All examples in this topic assume that the grid is bound to the Orders table of the Northwind database, unless stated otherwise.
The following example demonstrates how to display a row's visual index in its corresponding row selector by creating a style targeting the RowSelector type that displays the value of its ItemIndex property as its content. The style is then assigned to the RowSelectorPane.RowSelectorStyle attached property, which is set by the implict DataRow style.
XAMLCopy Code
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"> 
  <Grid.Resources> 
    <xcdg:DataGridCollectionViewSource x:Key="cvs_orders" 
                                       Source="{Binding Source={x:Static Application.Current}, 
                                                        Path=Orders}" /> 
 
    <Style x:Key="itemIndexSelectorStyle" 
           TargetType="{x:Type xcdg:RowSelector}"> 
      <Setter Property="Content" 
              Value="{Binding RelativeSource={RelativeSource Self}, Path=ItemIndex}"/> 
    </Style> 
    <Style TargetType="{x:Type xcdg:DataRow}"> 
      <Setter Property="xcdg:RowSelectorPane.RowSelectorStyle" 
              Value="{StaticResource itemIndexSelectorStyle}" /> 
    </Style> 
  </Grid.Resources> 
 
  <xcdg:DataGridControl x:Name="OrdersGrid" 
                            ItemsSource="{Binding Source={StaticResource cvs_orders}}" /> 
</Grid>

Requirements

Supported Frameworks: Microsoft .NET Framework version 3.5

See Also