I'm trying to get this to run
<RadzenDropDown TValue="string" Data="@_data" TextProperty="Text" ValueProperty="Value" />
@code{
private readonly IEnumerable<(string Text, string Value)> _data = new[] { ("Deutsch", "de-DE"), ("English", "en-US"), ("Espanol", "es-ES") };
}
This gets finally rendered to:
First guess would be an issue with named Tuples so
I tried using TextProperty="Item1" ValueProperty="Item2"
instead but this did not change anything.
Changing the data to:
public record DataRecord(string Text, string Value);
private readonly IEnumerable<DataRecord> _data = new[] { new DataRecord("Deutsch", "de-DE"), new DataRecord("English", "en-US"), new DataRecord("Espanol", "es-ES") };
is my current workaround but I would be happier if inline Tuples
would work as well
This is my final workaround I am currently using:
@typeparam TValue
<RadzenDropDown TValue="TValue" Data="@DataRecords" TextProperty="@(nameof(DataRecord.Text))" ValueProperty="@(nameof(DataRecord.Value))" />
@code {
private record DataRecord(string Text, TValue Value);
[Parameter]
public IEnumerable<(string, TValue)> Data { get; set; }
private IEnumerable<DataRecord> DataRecords => Data.Select(d => new DataRecord(d.Item1, d.Item2)).ToList();
}
I had to remove the tuple's names as this leads to build-errors. In order to get the RadzenDropDown
get the right things to show I've created an internal record
which properties can then be access by the DropDown. A class
would have the same effect, but I like the short syntax for records
Here is the related stackoverflow-question I've created.
This still exists. I use the current Radzen-Version and I encountered the same error