Method to reproduce
(telerik version 2018.1.220)
- Create a structure that has enum with [Flags] attribute as members
- Set the array of the above structure to SourceItems of RadPropertyGrid
- Set "Intersection" or "Union" for "PropertySetMode" of "RadProeprtyGrid"
- Run the application
- Changing enum member flags from PropertyGrid with FlagEnumEditor will not be applied.
In addition, the following exception occurs when changing the flag
---
Exception thrown: 'System.InvalidCastException' in mscorlib.dll
Exception thrown: 'System.InvalidCastException' in mscorlib.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll
System.Windows.Data Error: 8 : Cannot save value from target back to source. BindingExpression:Path=CurrentPropertySet[Types]; DataItem='PropertySetViewModel' (HashCode=30131813); target element is 'FlagEnumEditor' (Name=''); target property is 'Value' (type 'Object') InvalidCastException:'System.InvalidCastException: 'System.String' から 'enum_flags_test.MainWindow+EnumTest+Type' への無効なキャストです。
System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
System.String.System.IConvertible.ToType(Type type, IFormatProvider provider)
System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
Telerik.Windows.Controls.RadPropertyGrid.<>c__DisplayClass2b.<OnPropertySetViewModelChanged>b__28(Object s, PropertyChangedEventArgs e)
System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
Telerik.Windows.Controls.Data.PropertyGrid.PropertySet.OnPropertyChanged(String fileName)
Telerik.Windows.Controls.Data.PropertyGrid.PropertySet.set_Item(String property, Object value)'
---
Is there any workaround?
Your help would be welcomed.
---
MainWindow.xaml.cs
public
partial
class
MainWindow : Window
{
public
class
EnumTest
{
[Flags]
public
enum
Type
{
None = 0,
First = 1 << 0,
Second = 1 << 1,
}
public
Type Types {
get
;
set
; } = Type.None;
}
public
MainWindow()
{
InitializeComponent();
PropertyGrid1.Item =
new
EnumTest[] {
new
EnumTest() };
}
}
MainWindow.xaml
<
Window
x:Class
=
"enum_flags_test.MainWindow"
xmlns:local
=
"clr-namespace:enum_flags_test"
mc:Ignorable
=
"d"
Title
=
"MainWindow"
Height
=
"450"
Width
=
"800"
>
<
Grid
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
>
<
telerik:RadPropertyGrid
x:Name
=
"PropertyGrid1"
PropertySetMode
=
"Intersection"
/>
</
Grid
>
</
Window
>