Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxTagBox<TData, TValue>.SelectedDataItemsChanged Event

Fires when selection changes.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[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 Values and Tags properties are changed in code. This also includes the first render.

The SelectedDataItemsChanged 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