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

FlagEnumEditor: unsetting the last flag causes binding error

1 Answer 64 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
SPARE GmbH
Top achievements
Rank 2
SPARE GmbH asked on 17 Oct 2012, 02:27 PM
Hi,

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

1 Answer, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 18 Oct 2012, 09:19 AM
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,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PropertyGrid
Asked by
SPARE GmbH
Top achievements
Rank 2
Answers by
Maya
Telerik team
Share this question
or