ListBoxEdit.SelectionMode Property
Gets or sets the selection mode for the ListBoxEdit
control. This is a dependency property.
Namespace: DevExpress.Xpf.Editors
Assembly: DevExpress.Xpf.Core.v24.2.dll
NuGet Package: DevExpress.Wpf.Core
#Declaration
public SelectionMode SelectionMode { get; set; }
#Property Value
Type | Description |
---|---|
Selection |
A Selection |
#Remarks
The SelectionMode
property specifies how users can select items within the ListBoxEdit
control.
The ListBoxEdit
supports the following selection modes:
- Single (default)
- Users can select only one item at a time.
- Multiple
- Users can select multiple items by clicking with the mouse or pressing the Space bar.
- Extended
- Users can select multiple consecutive items by holding the Shift key while clicking. Holding Ctrl and clicking toggles an item’s selection state.
Each time the selection changes, the ListBoxEdit.SelectedIndexChanged event is fired.
Tip
The List
property returns a List
Use the List
Note
If the
List
is configured as a checked list, theBox Edit Selection
property is automatically set toMode Multiple
and cannot be changed.If the
List
is configured as a radio list, theBox Edit Selection
property is automatically set toMode Single
and cannot be changed.
#Example
The following code example creates a ListBoxEdit
control with multiple item selection enabled:
<dx:ThemedWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:local="clr-namespace:ListBoxEdit"
x:Class="ListBoxEdit.MainWindow"
Title="MainWindow" Height="800" Width="1000">
<Window.DataContext>
<local:MainViewModel />
</Window.DataContext>
<Grid>
<dxe:ListBoxEdit x:Name="listBoxEdit" HorizontalAlignment="Left" Margin="284,331,0,0" VerticalAlignment="Top" Height="213" Width="138"
SelectionMode="Multiple"
ItemsSource="{Binding Items}"
EditValue="{Binding SelectedItems, Mode=TwoWay}"
DisplayMember="Name"/>
</Grid>
</dx:ThemedWindow>
using DevExpress.Xpf.Core;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
namespace ListBoxEdit {
public partial class MainWindow : ThemedWindow {
public MainWindow() {
InitializeComponent();
}
}
public class MainViewModel : INotifyPropertyChanged {
public ObservableCollection<Item> Items { get; set; }
public List<Object> SelectedItems { get; set; }
public MainViewModel() {
Items = new ObservableCollection<Item>(Enumerable.Range(0, 10)
.Select(c => new Item {
Id = c,
Name = "Item " + c }));
SelectedItems = new List<Object>(){
Items[0],
Items[2]
};
}
public event PropertyChangedEventHandler PropertyChanged;
}
public class Item {
public int Id { get; set; }
public string Name { get; set; }
}
}
#Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SelectionMode 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.