CurrentItem Property
See Also  Example
Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > DataGridControl Class : CurrentItem Property

Gets or sets the grid's current master data item.

Syntax

Visual Basic (Declaration) 
Public Property CurrentItem As Object
C# 
public object CurrentItem {get; set;}

Return Value

A reference to the grid's current master data item. Can be a null reference (Nothing in Visual Basic) if the current item is not a master 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 retrieve the value of the ShipCountry and ShipCity properties of the current item and display them in TextBlocks located above the grid. Note that an item in a grid must be current in order for the information to be displayed.
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}"/> 
   </Grid.Resources> 
   <DockPanel>    
      <StackPanel Orientation="Horizontal" DockPanel.Dock="Top"> 
 
        <TextBlock Text="{Binding ElementName=OrdersGrid, Path=CurrentItem[ShipCountry]}"/> 
        <TextBlock Text=" - "/>  
        <TextBlock Text="{Binding ElementName=OrdersGrid, Path=CurrentItem[ShipCity]}"/> 
      </StackPanel>     
      <xcdg:DataGridControl x:Name="OrdersGrid" 
                            ItemsSource="{Binding Source={StaticResource cvs_orders}}" 
                            DockPanel.Dock="Bottom"> 
      </xcdg:DataGridControl> 
   </DockPanel> 
</Grid>

Remarks

The CurrentItem and SelectedItem properties may, or may not, be the same data item.

The CurrentItem and SelectedItem/SelectedItems properties must be set to a null reference (Nothing in Visual Basic) in order to reset them when the NavigationBehavior property is set to None.

Requirements

Supported Frameworks: Microsoft .NET Framework version 3.5

See Also