blazor-devexpress-dot-blazor-dot-dxlistbox-2-e74df71c.md
Provides access to the List Box’s selected value/item collection.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
[Parameter]
public IEnumerable<TValue> Values { get; set; }
| Type | Description |
|---|---|
| IEnumerable<TValue> |
The List Box’s values/items.
|
Use the Values property to access to the List Box’s list of item values/items from a bound data source. To respond to selection changes, handle the ValuesChanged event.
The Values property can return the following objects:
Value in the data source. An exception occurs in the following situations:
Value data type differs from the bound Values type.Value.<DxListBox Data="@Staff.DataSource"
TextFieldName="@nameof(Person.Text)"
@bind-Values="@SelectedStaff">
</DxListBox>
@code {
IEnumerable<Person> SelectedStaff { get; set; } = new List<Person>() { Staff.DataSource[0] };
}
The following code snippet demonstrates a sample implementation of the Person class.
public class Person {
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public Department Department { get; set; }
public string Text => $"{FirstName} {LastName} ({Department} Dept.)";
}
The ListBox Values property is strongly typed. You can use two-way binding only with IEnumerable collections. If you want to store data in other collections, for example, IList, use one-way binding:
<DxListBox Data="@Cities" Values="@Values" />
@code {
IList<string> Cities = new List<string>() {
"London",
"Berlin",
"Paris",
};
IList<string> Values { get; set; } = new List<string>() {
"Paris",
};
}
DevExpress.Blazor.IListBox<TData, TValue>.Values
See Also
DxListBox<TData, TValue> Class