Xceed DataGrid for WPF v7.2 Documentation
CurrentItem Property (DataGridControl)
Example 


Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > DataGridControl Class : CurrentItem Property
Gets or sets the grid's current master data item.
Syntax
'Declaration
 
Public Property CurrentItem As Object
'Usage
 
Dim instance As DataGridControl

Dim value As Object

 

instance.CurrentItem = value

 

value = instance.CurrentItem
public object CurrentItem {get; set;}

Property 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.
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.

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.
<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>
Requirements

Target Platforms: Windows 11, Windows, 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

DataGridControl Class
DataGridControl Members

Properties

SelectedItem Property