Is there a clever way to get the MVC scaffolding to render a dropdown or listbox for model properties that are enum values?
Example:
public class MyModel
{
public Color MyColor { get; set; }
public Option Options { get; set; }
}
public enum Color
{
None = 0,
Red = 1,
Blue = 2,
White = 3
}
[Flags]
public enum Option
{
NotSet = 0,
Option1 = 1,
Option2 = 2,
Option3 = 4,
Option4 = 8
}
For the “Color” property, a dropdown would be nice. And for the “Options” property, a combo box or list of checkboxes would be cool.
Is there any kind of support built into the MVC framework/tooling for this? Currently, Visual Studio just ignores the model properties of enum types when I create a View from the model.
What would be the best way to implement this?