7 Answers, 1 is accepted
0
Hi Daniel,
Maya
the Telerik team
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 ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Daniel
Top achievements
Rank 1
answered on 21 Sep 2011, 12:08 PM
yes. Thank you Maya.
0
Pavel
Top achievements
Rank 1
answered on 27 Jan 2012, 09:09 AM
How can I display localized text for enum value?
The PropertyGrid of Denis Vuyka supports IValueConverter for the displayed items and it was work.
The PropertyGrid of Denis Vuyka supports IValueConverter for the displayed items and it was work.
0
Pavel
Top achievements
Rank 1
answered on 27 Jan 2012, 03:49 PM
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;
}
}
}
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;
}
}
}
0
Intecom
Top achievements
Rank 1
answered on 23 Jun 2015, 03:18 PM
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.
0
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
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
0
Yang
Top achievements
Rank 1
answered on 22 Jul 2015, 03:18 PM
Thanks for the project. It solves my problem very well.