I can change the language of content in the property grid and everything around it with my CultureChangeEvent, but not the statically bound DisplayNames. Either I'd like them non-static or some way to update them as statics..
I have tried to get them in a non-static DataContext but failed, please help.
<telerik:RadPropertyGrid x:Name=
"SettingsPropertyGrid"
Item=
"{Binding Setting}"
SearchBoxVisibility=
"Collapsed"
SortAndGroupButtonsVisibility=
"Collapsed"
AutoGeneratePropertyDefinitions=
"False"
>
<telerik:RadPropertyGrid.PropertyDefinitions>
<telerik:PropertyDefinition Binding=
"{Binding Languages, Mode=TwoWay}"
GroupName=
"Localization"
DisplayName=
"{x:Static resx:SettingsModule_Resource.DisplayNameLanguage}"
/>
<telerik:PropertyDefinition Binding=
"{Binding MeasurementUnit, Mode=TwoWay}"
GroupName=
"Localization"
DisplayName=
"{x:Static resx:SettingsModule_Resource.DisplayNameUnit}"
/>
<telerik:PropertyDefinition Binding=
"{Binding DeviceId, Mode=TwoWay}"
GroupName=
"Developer Settings"
DisplayName=
"{x:Static resx:SettingsModule_Resource.DisplayNameDevice}"
/>
<telerik:PropertyDefinition Binding=
"{Binding LogLevel, Mode=TwoWay}"
GroupName=
"Developer Settings"
DisplayName=
"{x:Static resx:SettingsModule_Resource.DisplayNameLog}"
/>
</telerik:RadPropertyGrid.PropertyDefinitions>
</telerik:RadPropertyGrid>
Asked the question in an old post, I probably shouldn't have done that..
//Anders
9 Answers, 1 is accepted
You can check our documentation here for more information on our localization mechanisms, especially the section about using ResourceManager. This online resource might also be helpful.
You will need to define resource files for the different languages so that when the language is changed to have the display value updated.
Didie
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Created the following class in my localization folder:
class
CustomLocalizationManager : LocalizationManager
{
public
override
string
GetStringOverride(
string
key)
{
switch
(key)
{
case
"DisplayNameDevice"
:
return
SettingsModule_Resource.DisplayNameDevice;
case
"DisplayNameLanguage"
:
return
SettingsModule_Resource.DisplayNameLanguage;
case
"DisplayNameLog"
:
return
SettingsModule_Resource.DisplayNameLog;
case
"DisplayNameUnit"
:
return
SettingsModule_Resource.DisplayNameUnit;
}
return
base
.GetStringOverride(key);
}
}
How do i bind to this? the only thing that doesn't change language in my settings module is this "DisplayName". With my current DisplayName Binding as shown in my previous post the language only changes after a restart of the application, i want it to change directly, w/o restart. "On the fly"!
Thanks!
//Anders
You can set the ResourceKey similar to:
<telerik:PropertyDefinition... telerik:LocalizationManager.ResourceKey="DisplayName"/>
Didie
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Hi Telerik
This is not working for DisplayName of telerik:PropertyDefinition but working for telerik:RadButton and other controls as well.
I would really appreciate if you can share a sample project/code for our reference.
Thanks
Pritesh Patel
Could you elaborate what approach exactly you're using to localize the DisplayNames of the property definitions? Also, are you changing the culture of the application at runtime?
We don't have an example showing this precise scenario right now, but if I understand more about your setup I may be able to point you in the right direction.
Regards,
Petya
Telerik
- Hello
Petya,
Thank you for help.
I am using “Localization Using Custom Localization Manager” approach to localize the DisplayNames of the propertyGrid.
Step by step code written for custom localization are give following.
1. Create a custom Localization manager as following
public class CustomLocalizationManager : LocalizationManager
{
public override string GetStringOverride(string key)
{
switch (key)
{
//----------------------
case "lblProjectManager":
{
var temp = Enums.FindResource(key);
return temp;
}---------------------
}
return base.GetStringOverride(key);
}
}
2. In user control constructor set custom localization manager as following
public partial class DialogProjectAddView : UserControl
{
public DialogProjectAddView()
{
Telerik.Windows.Controls.LocalizationManager.Manager = new CustomLocalizationManager();
InitializeComponent();
// RadGridSamples.BeginInsert();
}
}
3. In Property Definition set resource key as following
<telerik:PropertyDefinition telerik:LocalizationManager.ResourceKey="lblProjectManager" OrderIndex="6" Binding="{Binding ExtAuthorisedSignatory, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" Description="Sets Authorised Signatory Name" />
The culture of the application set in On Startup method of application at runtime.
All the code running properly but display name show blank. Please help me to find reason for this error. If you need any more information you are free to contact.
Thanks…………………..
Regards
Pritesh Patel
In order to localize the DisplayName properties of property definitions, I'd suggest adopting data annotations. I'm attaching a sample application showing the approach. Please review it and let me know if it is helpful.
Regards,
Petya
Telerik
Hello
Petya,
Thank you
for help and support.
I
can't use adopting data
annotations in my project due to following to reason.
1. My project is create using MVVM so reference of resource file not
exit in Model
2. My project use entity frame
work created model class to I can
apply attributes to the members
Can we use other approach ?
Kind regards
Pritesh
The only other thing I can think of is to subscribe to the AutoGeneratingPropertyDefinition event of RadPropertyGrid and change the DisplayName for each PropertyDefinition there through the event arguments.
private
void
PropertyGrid1_AutoGeneratingPropertyDefinition(
object
sender, Telerik.Windows.Controls.Data.PropertyGrid.AutoGeneratingPropertyDefinitionEventArgs e)
{
if
(e.PropertyDefinition.DisplayName ==
"FirstName"
)
{
e.PropertyDefinition.DisplayName = PropertyGridResources.FirstName;
}
}
To comply with the MVVM paradigm, you can adopt EventToCommandBehaviour.
Regards,
Petya
Telerik