How to use an Enum as Source for a RadComboBox?

4 posts, 0 answers
  1. David Lino
    David Lino avatar
    13 posts
    Member since:
    Apr 2010

    Posted 29 Apr 2010 Link to this post

    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
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 29 Apr 2010 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. David Lino
    David Lino avatar
    13 posts
    Member since:
    Apr 2010

    Posted 29 Apr 2010 Link to this post

    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.

  5. David Lino
    David Lino avatar
    13 posts
    Member since:
    Apr 2010

    Posted 03 May 2010 Link to this post

    So?

    (Sry for the up, but I'm in kinda hurry for this)
Back to Top