Back to Devexpress

DxListBox<TData, TValue>.ValuesExpression Property

blazor-devexpress-dot-blazor-dot-dxlistbox-2-c6233373.md

latest2.8 KB
Original Source

DxListBox<TData, TValue>.ValuesExpression Property

Specifies a lambda expression that identifies the Values property’s bound values when the List Box is placed in the EditForm.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public Expression<Func<IEnumerable<TValue>>> ValuesExpression { get; set; }

Property Value

TypeDescription
Expression<Func<IEnumerable<TValue>>>

A lambda expression that identifies bound values.

|

Remarks

You can add the List Box editor to Blazor’s standard EditForm component to validate the Values property value. In this case, the ValuesExpression property is used to obtain metadata about values bound to the Values property.

You should specify the ValuesExpression property if you handle the ValuesChanged event and cannot use two-way binding.

razor
<DxListBox Data="@Strings" 
           Values="@values"
           ValuesExpression="@(() => values)"
           ValuesChanged="@((IEnumerable<string> v) => values = v)" />

@code {
    IEnumerable<string> values = null;
    @* ... *@
    void ValuesChanged(IEnumerable<string> MyStrings) {
        @* ... *@
    }
}

The ValuesExpression property is set internally if you use the @bind attribute for the Values property to implement two-way binding.

razor
<DxListBox Data="@Strings" ...
          @bind-Values="@Values">
</DxListBox>

@code {
    IEnumerable<string> newValues = null;
    IEnumerable<string> Values { get => newValues; set { newValues = value; } }
    @* ... *@
}

The following exception occurs if you do not use two-way binding or the ValuesExpression property:

The ‘ValuesExpression’ or ‘ValueExpression’ property is required. Use two-way binding (‘bind-Value’ or ‘bind-Values’) to define these properties automatically.

See Also

DxListBox<TData, TValue> Class

DxListBox<TData, TValue> Members

DevExpress.Blazor Namespace