DxListBox<TData, TValue>.SelectedItemsChanged Event
Fires after the selection changes.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v23.1.dll
NuGet Package: DevExpress.Blazor
Declaration
[Parameter]
public EventCallback<IEnumerable<TData>> SelectedItemsChanged { get; set; }
Parameters
Type | Description |
---|---|
IEnumerable<T> | A collection of selected items. |
Remarks
The SelectedItemsChanged
event fires each time the selection changes.
We recommend that you use the SelectedItemsChanged event to access selected items’ data source objects when the following two conditions are met:
- Two-way binding is used for the Values property.
- The TextFieldName property is specified.
<DxListBox Data="@Staff.DataSource"
ValueFieldName="@nameof(Person.Id)"
TextFieldName="@nameof(Person.Text)"
@bind-Values="@Values"
SelectedItemsChanged="@((IEnumerable<Person> values) => SelectedItemsChanged(values))">
</DxListBox>
<p>@msg</p>
@code {
string msg;
IEnumerable<int> Values { get; set; } = Staff.DataSource.Take(12).Select(t => t.Id);
void SelectedItemsChanged(IEnumerable<Person> values) {
@* Only one item is present in the collection for single selection List Box *@
msg = values.First().FirstName + " " + values.First().LastName + " is selected";
}
}
In all other cases, when you need to only get the value of the selected items, use the ValuesChanged event instead of SelectedItemsChanged
.
See Also