PropertyEditor Localization

Grids for WPF Forum

Posted 15 years ago by johannes. g.
Version: 4.5.0487
Avatar
hello,

does anybody know how to localize the "description"-part in propertygrid?

the object i want to edit via propertygrid has a property as follows..

[Description("the description")]
public virtual String MyProperty
i've already realized to localize the name of the property via

<propgrid:PropertyGrid.PropertyEditors>
<!-- localized Name -->
<propgrid:PropertyEditor PropertyName="MyProperty" NameTemplate="{StaticResource PropertyNameTemplateMyProperty}" />
</propgrid:PropertyGrid.PropertyEditors>
and a template:

<DataTemplate x:Key="PropertyNameTemplateMyProperty">
<TextBlock Margin="2,0,0,0" VerticalAlignment="Center" Text="{Resx ResxName=MyProject, Key=PropertyEditor.Property.MyProperty}" />
</DataTemplate>
that works fine.
but how to localize the description? i have no idea..

thanks in advance.

Comments (3)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Johannes,

You can localize the DescriptionAttribute just as you would with the WinForms PropertyGrid. This article explains how this can be done.

You can also build something similar for the DisplayNameAttribute, so that you don't have one implementation for the DisplayName and one for the Description.

Hope this helps.


Actipro Software Support

Posted 15 years ago by johannes. g.
Avatar
thanks a lot!

that works fine. but is seems that a localization made this way is not changeable at runtime, right? any suggestions how to realize a language switch at runtime?
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Johannes,

You should be able to change it during runtime. As the article notes, you would need to remove the code that "caches" the localized string and just return the results of the SR.GetString method. Alternatively, you could have the attribute listen for some global event that is fired when the culture is changed, and have them clear their cache.

In order for the PropertyGrid to pick up the changes, you would need to call the Refresh method. If the object has not been loaded yet, then this wouldn't be an issue (as it will pick up the changes when you set the SelectedObject).


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.