I am trying to bind a value from a FluentListBox to a variable via the following code:
@using Microsoft.Fast.Components.FluentUI;
@page "/test"
<FluentListbox @bind-Value=_value>
<FluentOption Value=@("First Value")>First Value</FluentOption>
<FluentOption Value=@("Second Value")>Second Value</FluentOption>
<FluentOption Value=@("Third Value")>Third Value</FluentOption>
</FluentListbox>
<h1>@_value</h1>
@code {
private string _value = string.Empty;
}
Trying this out in a new Blazor project shows that _value
does not change when selecting a new value.
When I manually set _value
to "First Value", then it also shows as selected in the FluentListBox. So binding works atleast in one-way, but not the other.
When I add a FluentSelect-Component with the same values and also bind _value
to that, then I can change the value via the FluentSelect and can also observe how the selection in the FluentListBox changes.
So how do I achieve similar behaviour in the FluentListBox. How can I bind _value
to FluentListBox, so selecting "Second Value" sets _value
to "Second Value"