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
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.
Have you tried this??
YourEnum abc = (YourEnum) Enum.Parse(typeof(YourEnum), yourObject.ToString());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With