I want to make a ComboBox whose elements are a subset of the members of an enum
type. If I once knew the syntax for this, I can’t remember it now!
I’m basically looking for the markup equivalent of throwing this into the constructor:
cboState.Items.Add(InvoiceState.Ready);
cboState.Items.Add(InvoiceState.Waiting);
cboState.Items.Add(InvoiceState.Finished);
Simply binding to Enum.GetValues
doesn’t work because there are values I don’t want to include. If these were in attribute values, I could use {x:Static core:InvoiceState.Ready}
, etc. But they’re not attribute values.
<ComboBox Name="cboState">
<!-- what goes here? -->
<core:InvoiceState>Ready</core:InvoiceState> <!-- does not work -->
</ComboBox>