I am using the following code to produce a ListBox from a concatenated string:
@page "/"
<RadzenListBox TValue="object" Multiple="true" Data="data.Split('|').Select(_data => new { Text = _data.Split('~')[0], Value = _data.Split('~')[1] })" TextProperty="Text" ValueProperty="Value" Change="(args => OnChange(args))" />
<RadzenListBox TValue="object" Multiple="false" Data="data.Split('|').Select(_data => new { Text = _data.Split('~')[0], Value = _data.Split('~')[1] })" TextProperty="Text" ValueProperty="Value" Change="(args => OnChange(args))" />
@code {
string data = string.Join
(
'|',
string.Join('~', "Choice 1", "Choice1"),
string.Join('~', "Choice 2", "Choice2"),
string.Join('~', "Choice 3", "Choice3")
);
void OnChange(object args)
{
string selection;
if (args is IEnumerable<string>)
{
selection = string.Join('|', (IEnumerable<string>)args);
}
else
{
selection = args.ToString();
}
}
}
As the mouse hovers over each value in the ListBox the background color changes to indicate the selection. The OnChange method gets processed successfully. However the ListBox does not show the selected items; the backgrounds do not change color nor do the checkboxes get checked.