I have a very simple scenario with a TelerikDropDownList, like the following:
<TelerikDropDownList Data="@foundComponents"
@bind-Value="@componentId"
ValueField="ComponentId"
TextField="Description">
</TelerikDropDownList>
Then, I have declared the required properties and then there is my method that loads the data in the "foundComponents" collection.
@code {
protected string? componentId;
protected IEnumerable<Component>? foundComponents;
...
private async Task SearchComponentAsyncHandler()
{
foundComponents = (await JsonSerializer.DeserializeAsync<ZollerBrowseResult>(responseStream)).BrowseResult?.Select(x => x.Component);
}
}
and this is my "ZollerBrowseResult" model and its related classes:
public class ZollerBrowseResult
{
public required BrowseResult[]? BrowseResult { get; set; }
}
public class BrowseResult
{
public required Component Component { get; set; }
}
public class Component
{
public string? ComponentId { get; set; }
[JsonPropertyName("Component.ComponentId")]
private string Component_ComponentId { set { ComponentId = value; } }
public string? Description { get; set; }
public Article? Article { get; set; }
}
For some reason, when I run the application, the Dropdown doesn't show the Description property, it shows the class FullName instead.
I don't understand what I am doing wrong here.