I cant bind to an object with nullable enums using auto generated properties.
I get a silent error for every nullable enum property
System.Windows.Data Error: 1 : Cannot create
default
converter to perform
'two-way'
conversions between types
'System.Nullable`1[Data.EF5.Enumerations.Unit]'
and
'System.String'
. Consider
using
Converter property of Binding. BindingExpression:Path=Unit1; DataItem=
'Mb'
(HashCode=13923471); target element
is
'TextBox'
(Name=
''
); target property
is
'Text'
(type
'String'
)
Part of the enum looks like this (localized)[TypeConverter(
typeof
(EnumToLocalizedName))]
public
enum
Unit:
int
{
[Display(Description =
" "
, ResourceType =
typeof
(Resources.Resource))]
Unit0,
[Display(Description =
"°C"
, ResourceType =
typeof
(Resources.Resource))]
Unit1
....
}
Non-nullable enums shows up in a combobox. How can I show my nullable enums the same way, without losing localization?
Thanks
6 Answers, 1 is accepted
Currently nullable enums are not supported by RadPropertyGrid in scenarios with auto-generated fields. We will do our best to add this feature in some of our future internal builds. I will write to you, in order to notify you as soon as the mentioned version is available.
All the best,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Still one problem remaining. How can I localize the enum names for the combobox? My typeconverter attribute is ignored. What attributes does the PropertyGrid require? Thanks
We will need some more time, in order to check this. I will contact you tomorrow, in order to notify you of the results of our research. Please, excuse me for this delay.
Regards,Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
We have tested this scenario on our side and it appears that currently there is no easy workaround for this scenario. Would it be possible for you to use a non-nullable enum property and add a value that would mimic the null value, in the enum definition? The internal build that introduces support for Nullable enums will be released later today/tomorrow, but unfortunately the TypeConverter is not yet working properly with it.
All the best,Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
It seems that the EnumDataSource that we internally use in RadPropertyGrid fails to invoke the TypeConverter properly. We will need some more time to investigate this. I will contact you as soon as we have any updates.
All the best,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.