I have binded a list of enum to a combobox. Now I want to get the SelectedItem
return the enum, which currently returns it as type object
. How do I convert this object to my enum?
My framework is silverlight on windows-phone-7
I have binded a list of enum to a combobox. Now I want to get the SelectedItem
return the enum, which currently returns it as type object
. How do I convert this object to my enum?
My framework is silverlight on windows-phone-7
Have you tried this??
YourEnum abc = (YourEnum) Enum.Parse(typeof(YourEnum), yourObject.ToString());
Cast it directly:
MyEnum selected = (MyEnum)cboCombo.SelectedItem;
Note that you can't use the as
cast in this case since an Enum
is a value type.