Hi,
I am looking to use strongly-typed IDs in my project and it does not appear to be possible to achieve this with Telerik UI for Blazor. Instead, the popup does not go away on selection and the bound value does not update.
Note that this is not a request for binding to arbitrary complex types. I believe it would be sufficient to support value types that implement ToString / IParsable.
For example:
https://blazorrepl.telerik.com/QxvcQIPR55jFAGMF00
<h1>Hello, Telerik REPL for Blazor!</h1>
<h2>Selected Value: @SelectedValue</h2>
<TelerikDropDownList Data="@Data"
@bind-Value="@SelectedValue"
TextField="@nameof(SelectItem.DisplayName)"
ValueField="@nameof(SelectItem.Value)"
DefaultText="Select ...">
</TelerikDropDownList>
@code {
public MyValue SelectedValue {get; set;}
public SelectItem[] Data { get; } = new[] {
new SelectItem(1),
new SelectItem(2),
};
public readonly struct MyValue : System.IParsable<MyValue> {
public int Value {get;}
public MyValue(int value) {
this.Value = value;
}
public override string ToString() {
return Value.ToString();
}
public static MyValue Parse(string str, IFormatProvider provider) {
return new(int.Parse(str, provider));
}
public static bool TryParse(string str, IFormatProvider provider, out MyValue value) {
value = new(int.Parse(str, provider));
return true;
}
}
public class SelectItem {
public SelectItem(int value) {
Value = new(value);
DisplayName = $"Item {value}";
}
public MyValue Value {get; set;}
public string DisplayName {get; set;}
}
}
Thanks,
Ben