I have an enum
public enum Positions : byte
{
Manager = 0,
CEO = 1,
Lawyer =2,
Intern =3,
Janitor = 4,
}
Is it possible to get a subset of these emums to bind with a ComboBox in WPF? Say only those enum values <=2 and >= 0? I was trying:
var subset = from p in Positions where p <= 2 && p >= 0 select p;
myComboBox.ItemsSource = subset;
without success (Positions is flagged as error with “Could not find an implementation of the query pattern…”)
I was thinking that this would be nice to use LINQ on, but if there’s another simple way, that would be interesting too.
Thanks,
Dave
You’ll need to get the enum values and cast it to the proper type: