A newer version of this page is available. Switch to the current version.

DataControlBase.SelectedItems Property

Gets or sets data objects that correspond to rows (or nodes in TreeListView) currently selected within a View.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v19.1.Core.dll


public IList SelectedItems { get; set; }
Public Property SelectedItems As IList

Property Value

Type Description

The list which contains data objects corresponding to selected rows.


A collection that is bound to the SelectedItems property should be initialized.

If the grid is in Server Mode, the SelectedItems property always returns an empty list.

To learn more, see Obtaining Selected Rows and Cells.


When engineering a WPF application using the Model View ViewModel (MVVM) architectural pattern, you may be required to specify selected items in a Model or ViewModel. In this instance, a collection of selected items should be initialized in the Model or View Model before it is bound to the grid's SelectedItems property. Otherwise, it will not be populated with items selected within the grid.


This example demonstrates how to bind GridControl's selected rows to a property in ViewModel in a MVVM-based application. The SelectionAttachedBehavior helper class used in this sample, provides a bindable SelectedItemsSource property, that can be used to define selection at the ViewModel level. Note, we made the SelectionAttachedBehavior class as generic as possible, and the same approach can also be used for other controls that support multiple selection. This example demonstrates how this can be done when working with the standard ListBox control, as well as with the standard DataGrid.

<Window x:Class="WPFGridMVVMSelection.MainWindow"
        Title="MainWindow" Height="350" Width="525">
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        <dxg:GridControl ItemsSource="{Binding Source}" AutoGenerateColumns="AddNew" SelectionMode="Row" SelectedItems="{Binding Selection}" >
                <dxg:TableView NavigationStyle="Row" />
        <ListView SelectionMode="Multiple" Grid.Column="1" ItemsSource="{Binding Source}"
                  dx:SelectionAttachedBehavior.SelectedItemsSource="{Binding Selection}" />
        <dxg:GridControl Grid.Column="2" ItemsSource="{Binding Source}" AutoGenerateColumns="AddNew" SelectionMode="Row" SelectedItems="{Binding Selection}"> 
                <dxg:TableView NavigationStyle="Row" />
        <dxg:GridControl Grid.Column="3" ItemsSource="{Binding Source}" AutoGenerateColumns="AddNew" SelectionMode="Row" SelectedItems="{Binding Selection}">
                <dxg:CardView NavigationStyle="Row" />
        <Button Grid.Row="1" Grid.ColumnSpan="2" Content="Select Odd Rows" Command="{Binding SelectOddRowsCommand}"/>
        <Button Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" Content="Delete Selected Rows" Command="{Binding DeleteSelectedRowsCommand}" />
See Also