Skip to content

Instantly share code, notes, and snippets.

@EdCharbeneau
Created May 21, 2019 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdCharbeneau/137004e262e41e8efebcb29875646583 to your computer and use it in GitHub Desktop.
Save EdCharbeneau/137004e262e41e8efebcb29875646583 to your computer and use it in GitHub Desktop.
Telerik UI for Blazor Drop Down Enum
<TelerikDropDownList Data="@ModeList" TextField="Text" ValueField="Value" bind-Value="@selectedValue">
</TelerikDropDownList>
<span>Selected: @((Modes)selectedValue)</span>
@functions {
int selectedValue { get; set; } = 0;
public class ModeViewModel
{
public int Value { get; set; }
public string Text { get; set; }
}
IEnumerable<ModeViewModel> ModeList = Enum.GetValues(typeof(Modes))
.Cast<Modes>()
.Select(m => new ModeViewModel { Text = m.ToString(), Value = (int)m });
public enum Modes
{
Play = 0,
Stop = 1,
FastForward = 2,
Rewind = 3
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment