I have an [Flags] Enum that contains some datapoints that I want to collect. My goal is to display and bind each value(each bit) as an individual checkbox for the user to check. However, I do not know how to bind individual values of an Flags enum to a component, nor if it is even possible. To better explain my point:
Say this is my enum:
[Flags]
public enum DataPoints{
Large = 1,
Soft = 2,
Green = 4,
Round = 8
}
Then I'd want a property in my form's model of DataPoints type that can hold those values:
//possible data points like:
// 9: Round and Large
// 6: Soft and Green
public DataPoints Data;
I was thinking something like the following but I don't think you can bind individual values/bits of an enum to a component like that:
@foreach (DataPoints datum in Enum.GetValues(typeof(DataPoints)))
{
<CheckBox @bind-Value="what? Data.datum?"></CheckBox>
}