wpf-devexpress-dot-xpf-dot-grid-dot-datacontrolbase-b7d921aa.md
Gets or sets a list of data objects that correspond to rows/nodes selected within a View.
Namespace : DevExpress.Xpf.Grid
Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll
NuGet Package : DevExpress.Wpf.Grid.Core
public IList SelectedItems { get; set; }
Public Property SelectedItems As IList
| Type | Description |
|---|---|
| IList |
A list of data objects that correspond to rows/nodes selected within a View.
|
In Multiple Row Selection mode, the GridControl‘s SelectedItems collection is populated with items in the same order rows/nodes are selected.
The GridControl removes filtered out items from the SelectedItems collection if you apply a filter.
When the GridControl works in Server Mode, the SelectedItems collection returns an empty list. Use the DataControlBase.GetSelectedRowHandles and DataControlBase.GetRow / DataControlBase.GetRowAsync methods to obtain row handles and data items.
When you work with the master-detail GridControl, its SelectedItems collection contains items only from the master GridControl. To obtain selected detail records in a DataControlDetailDescriptor:
To get selected nodes ordered by visible indexes, use the TreeListControlBase.GetSelectedNodes method. To get row handles of selected items ordered by visible indexes, use the DataControlBase.GetSelectedRowHandles method.
Refer to the Binding to a Collection of Selected Items topic for more information.
The following code sample binds the ListBoxEdit to the SelectedItems collection to show the GridControl‘s selected rows in the ListBox:
<dxg:GridControl x:Name="grid" SelectionMode="Row" ... />
<GroupBox Header="Selected Records">
<dxe:ListBoxEdit ItemsSource="{Binding SelectedItems, ElementName=grid}"
DisplayMember="Name"/>
</GroupBox>
The following code snippets (auto-collected from DevExpress Examples) contain references to the SelectedItems property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
wpf-data-grid-select-rows-that-contain-specific-value/CS/DXGrid_SelectRows/Window1.xaml#L15
</Grid.RowDefinitions>
<dxg:GridControl ItemsSource="{Binding Products}" AutoGenerateColumns="AddNew" SelectionMode="Row" SelectedItems="{Binding Selection}">
<dxg:GridControl.View>
wpf-data-grid-bind-selected-rows-to-viewmodel-property/CS/GridMVVMSelection/MainWindow.xaml#L19
SelectionMode="Row"
SelectedItems="{Binding Selection}">
<dxg:GridControl.View>
See Also