Skip to main content
All docs
V24.1

DxTagBox<TData, TValue>.SelectedDataItemsChanged Event

Fires when selection changes.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.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 SelectedItemsChanged event to respond to item selection changes. This event fires in the following cases:

  • When users change item selection.
  • When Values and Tags properties are changed in code. This also includes 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.
<DxTagBox Data="@Staff.DataSource" @bind-Values="@Values"
          ValueFieldName="@nameof(Person.Id)"
          TextFieldName="@nameof(Person.Text)"
          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) {
        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