In my example code I have two buttons and one dropdown.
dropdown data consists of a simple class, filled with 5 items:
public class Employee
{
public int UniqueID { get; set; }
public int ID { get; set; }
public string Name { get; set; }
public string Address { get; set; }
}
Value property is set to Name
And the bind-Value is set to a variable values
<RadzenDropDown AllowSelectAll="false" Data="@employees" Multiple="true" Placeholder="Select name..." style="width: 316px" TextProperty="Name" ValueProperty="Name" Name="Dropdown0" TValue="IEnumerable<string>" @bind-Value="@values">
</RadzenDropDown>
In my two buttons I set the variable values like this:
public async Task Button1()
{
values = new string[] { "Johan Svensson 3", "Johan Svensson 4" };
}
public async Task Button2()
{
values = new string[] { "Johan Svensson 2","Johan Svensson 1" };
}
Now the strange part, when I click button1 the dropdown change the selected values just fine:
When I click button 2 the dropdown shows it has 4 values:
And if I click button 2 a second time it shows it has 2 values, the correct ones from button 2
And if I click button 1 again it shows four values, click button 1 again and it shows 2 values, and so it goes on.
What am I doing wrong here?