Skip to main content
All docs
V24.2

DxListBox<TData, TValue>.SelectedDataItemsChanged Event

Fires when selection changes.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public EventCallback<SelectedDataItemsChangedEventArgs<TData>> SelectedDataItemsChanged { get; set; }

Event Data

The SelectedDataItemsChanged event's data class is SelectedDataItemsChangedEventArgs<TData>. The following properties provide information specific to this event:

Property Description
ChangeSource Identifies an action that causes selection change. Inherited from SelectionChangedEventArgs.
DataItems Returns a collection of currently selected items.

Remarks

Handle the SelectedDataItemsChanged event to respond to item selection changes. This event fires in the following cases:

  • When users change item selection.
  • When Value and Values properties are changed at runtime or in code. This also refers to the first render.

The SelectedItemsChanged event allows you to use the following argument properties in a handler:

  • ChangeSource to identify an action that causes selection change.
  • DataItems to obtain information about currently selected items.
<DxListBox Data="@Staff.DataSource"
          ValueFieldName="@nameof(Person.Id)"
          TextFieldName="@nameof(Person.Text)"
          @bind-Values="@Values"
          SelectedDataItemsChanged ="(SelectedDataItemsChangedEventArgs<Person> args) =>
                                     OnSelectedDataItemsChanged(args)" />

<p>@msg</p>

@code {
    string msg;

    IEnumerable<int> Values { get; set; } = Staff.DataSource.Take(12).Select(t => t.Id);

    void OnSelectedDataItemsChanged(SelectedDataItemsChangedEventArgs<Person> args) {
        // Only one item is present in the collection for single selection List Box
        if (args.ChangeSource == SelectionChangeSource.ParameterChange) 
            msg = "Selection changed in code. The selected item: " +
                args.DataItems.First().FirstName + " " + args.DataItems.First().LastName;
        else 
            msg = "Selection changed by a user action. The selected item: " +
                args.DataItems.First().FirstName + " " + args.DataItems.First().LastName;
    }
}
See Also