Hello, I'm programmatically setting the selected list (/from/ the available selection) on a MultiSelect.
It's bound to a List<string> that is part of a class: data.Value.
The MultiSelect is part of a "child" component that I use on more than one page.
On initial load, the List<string> that it is bound to is freshly instantiated in the class: public List<string> Value {get; set; } = new();
The very first time the code populates the list, the UI properly reflects the associated names (using key/value pairs from a dictionary).
After that, the UI doesn't change with further updates to the list.
My original code had Value.Clear() and then Value.Add(<new string values>) as required.
On a hunch, I changed it to re-instantiate the List instead of Value.Clear(), and now the UI refreshes as I expect it to.
I see the example https://docs.telerik.com/blazor-ui/components/multiselect/refresh-data first List.Clear()'s the List, then re-instantiates it, which I find odd. Why .Clear() if you're going to re-instantiate it?
void ClearSelected()
{
TheValues.Clear();
TheValues = new List<int>(TheValues);
}
1) Is it supposed to work with .Clear() and then add new items after the first time?
2) Why does it work the first time with adding new items?
3) Am I doing something incorrectly?
4) Why does the example .Clear() and then re-instantiate it?
Thanks!