FlagEnumEditor: unsetting the last flag causes binding error

2 posts, 1 answers
  1. SPARE GmbH
    SPARE GmbH avatar
    18 posts
    Member since:
    Mar 2012

    Posted 17 Oct 2012 Link to this post


    I encountered the following when using the FlagEnumEditor in my RadPropertyGrid:

    If you unset the last remaining flag using the FlagEnumEditor (unchecking the last checked checkbox, NOT setting the None Flag (value zero) ), a binding error occurs and the data is not set correctly.

    Error Message:

    System.Windows.Data Error: 7 : ConvertBack cannot convert value '' (type 'String'). BindingExpression:Path=Flags; DataItem='MyClass' (HashCode=49455573); target element is 'FlagEnumEditor' (Name=''); target property is 'Value' (type 'String') FormatException:'System.FormatException:  is not a valid value for MyFlags. ---> System.ArgumentException: Must specify valid information for parsing in the string.

    ... where MyClass is the type of the data context (Item of RadPropertyGrid) and MyFlags is the flags enum type.

    If you just use the None Flag, everything works fine.

    Suggested behavior: if the string value for converting back is empty, the flag enum should be set to zero.

    I was going to create an Issue for this in the PITS, but there was no category for RadPropertyGrid...

    Kind Regards
  2. Answer
    Maya avatar
    4062 posts

    Posted 18 Oct 2012 Link to this post

    Hello Alfred,

    The thing is that when you unselect all items, the value is null. And we cannot set it directly to None (0) as in some cases such item (None) may not be defined.

    Kind regards,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top