Works With Enums

8 posts, 0 answers
  1. Daniel
    Daniel avatar
    5 posts
    Member since:
    Aug 2011

    Posted 19 Sep 2011 Link to this post

    Hello.

    How to bind PropertyGrid to object with Enum property  (EF Code first).

    Thank's.
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 20 Sep 2011 Link to this post

    Hi Daniel,

    Generally, if you bind RadPropertyGrid to an item containing an enum property, the generated filed would be a combo box one, giving you the opportunity to change the enum value. I am sending you a sample project illustrating it. Is that the behavior you require ? 

    Greetings,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Daniel
    Daniel avatar
    5 posts
    Member since:
    Aug 2011

    Posted 21 Sep 2011 Link to this post

     yes. Thank you Maya.
  5. Pavel
    Pavel avatar
    8 posts
    Member since:
    Aug 2011

    Posted 27 Jan 2012 Link to this post

    How can I display localized text for enum value?
    The PropertyGrid of Denis Vuyka supports IValueConverter for the displayed items and it was work.

  6. Pavel
    Pavel avatar
    8 posts
    Member since:
    Aug 2011

    Posted 27 Jan 2012 Link to this post

    I found the solution myself, dig deeper in the source. Need add Description attribute to enum values.
    enum LineStyle
        {
            [LocalizeDescription("LineStyle.SOLID")]
            SOLID,
            [LocalizeDescription("LineStyle.DOT")]
            DOT,
            [LocalizeDescription("LineStyle.DASH")]
            DASH,
        }
    where
        [AttributeUsage(AttributeTargets.Property  | AttributeTargets.Field)]
        public class LocalizeDescriptionAttribute : DescriptionAttribute
        {
            public LocalizeDescriptionAttribute(string description)
                : base(description)
            {}

            public override string Description
            {
                get
                {
                    DescriptionValue = RM.GetString(DescriptionValue); // get localized text
                    return base.Description;
                }
            }
        }
  7. Intecom
    Intecom avatar
    7 posts
    Member since:
    Apr 2013

    Posted 23 Jun 2015 Link to this post

    But what if enum is from third-party code and we should display localized text for its value?

    I mean it is not possible to modify enum's code.

     

  8. Stefan X1
    Admin
    Stefan X1 avatar
    517 posts

    Posted 26 Jun 2015 Link to this post

    Hello George,

    Since such attributes cannot be added at run-time, I can suggest you take a look at the Binding to an enum with localization article as a possible approach is discussed in it. Note, that in order the proposed IValueConverter to be respected, you need to set the AutoGenerateBindingPaths property of RadPropertyGrid to "False". You can also check the Unbound Mode article for more information.

    Hope this helps.

    Best Regards,
    Stefan
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  9. Yang
    Yang avatar
    5 posts
    Member since:
    Jun 2015

    Posted 22 Jul 2015 in reply to Maya Link to this post

    Thanks for the project. It solves my problem very well.
Back to Top
UI for WPF is Visual Studio 2017 Ready