This is a migrated thread and some comments may be shown as answers.

How to use an Enum as Source for a RadComboBox?

3 Answers 231 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
David Lino
Top achievements
Rank 1
David Lino asked on 29 Apr 2010, 01:41 PM
Hi, I'm willing to use an Enum as source of a combo box, so I can handle the selection using something like this:

public enum MyEnum: byte { Normal , Diff }
    public partial class Dialog : Window
    {
          
        public Dialog()
        {
            InitializeComponent();       
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            MyEnum x = (MyEnum)myComboBox.SelectedItem;
            switch ( x ){
                case MyEnum .Normal : // do something
                         break;
                case MyEnum .Diff : // do somethiing
                         break;
            }
        }
   }

Thanks

3 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 29 Apr 2010, 02:46 PM
Hello David,

Please, check the following blog post, demonstrating the scenario you need:
http://blogs.telerik.com/valerihristov/posts/09-06-12/binding_a_combobox_to_enum_values_with_radcontrols_for_silverlight.aspx

Greetings,
Valeri Hristov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
David Lino
Top achievements
Rank 1
answered on 29 Apr 2010, 03:51 PM
Hi again.

There you said: "Of course, if you create the EnumModel in the code behind you will be able to provide any Enum Type you want – in this case the modifications in the TypeTypeConverter class will not be necessary."

Could you put a example of How would I do this in my code?

When I'm trying to use my own enums I get this error on the "EnumType" field on XAML: The type reference cannot find a public type named "..."

Thanks.

0
David Lino
Top achievements
Rank 1
answered on 04 May 2010, 01:57 AM
So?

(Sry for the up, but I'm in kinda hurry for this)
Tags
ComboBox
Asked by
David Lino
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
David Lino
Top achievements
Rank 1
Share this question
or