Wouldn’t it be handy to have a dropdown component that is populated with all the elements of an enum (enumeration type) simply by providing the component the enum type? Of course it would! That’s why I created one.
This version (SelectEnumBindText) allows binding to the text element of the selected enum. That is if you need the name or description from the enum to be bound to some value then this is the component for you.
If you wrap the component inside an EditForm then the component will also indicate when it has been modified with a green outline like the InputTextBCA component does. You can also have the green outline removed after saving the EditForm data by adding a little code to the parent component’s submit handler. This is demonstrated in the Blazor Component Authority demonstration app. The code that implements the example is there too.
It also has a OnChanged event callback parameter that can be used in addition to binding to the text value. This OnChanged parameter can be handy if you want to cause some other change in the UI, based on what the user selects, such as filtering or hiding and showing UI elements.
I’ve started working on a SelectEnumBindInt version that will allow binding to the integer value of the selected enum. I expect to have that ready next week so check back then if that’s what you need. I hope someone finds this component useful. Please let me know if you do or have any suggestions for improvement.