Category name translation

Grids for WPF Forum

Posted 1 month ago by Procam
Version: 18.1.1

There is a way how to deal with the text of Category name using CategoryEditor? For example, for property name I use this PropeertyEditor:

			<TextBlock  x:Name="txtProperty"  Margin="4,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Center">
				<TextBlock.Text >
					<MultiBinding Converter="{StaticResource TranslationConverter}">
						<Binding ElementName="txtProperty" Path="."></Binding>
						<Binding Path="DisplayName"/>

so, that way I am able to translate the property name by means of my converter

There is some way how, in a similar way to the code above, to deal with the category name text?

Comments (5)

Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA


If you mean you wish to localize the text for the category name that is displayed above properties when properties are categorized in the PropertyGrid, you would have two options...

1) Clone and update the default Style we set to the PropertyGrid.DefaultCategoryItemContainerStyle property.  The Style we set there has a Template set that is where the TextBlock is.  This would require you to have our default styles/templates.


2) If you use the DisplayAttribute on your properties instead of DisplayNameProperty/CategoryAttribute, you can localize the string values using .NET string resources.  That overall might be an easier way to go since DisplayAttribute is made for string localization.

Actipro Software Support

Posted 1 month ago by Procam


regarding the 2. point, in some of the properties we use the three attributes (Category, DisplayName, and Display attribute), e.g.:

[Category("Graphic"), DisplayName("Color"), Display(Order = 3), SetModified]
        public virtual Color LineColor

but I do not understand how can I deal with the Category name, as you advised, using the Display attribute instead of the DisplaName/Category attribute? The DisplayName attribute we use for dealing with the property name, as shown in our xaml code above.

Regarding the 1. point, do you have some sample code? I can not find any in the sample app.

Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA


Yes the link for DisplayAttribute in the previous reply points to our documentation (see below) on using that attribute and an example.  The one attribute can replace the use of the others.

From Documentation

This code shows an example of applying DisplayAttribute to set sort order (via Order), category (via GroupName), display name (via ShortName), and description (via Description) for a property:

public class Foo {
	[Display(Order = 4, GroupName = "Common", ShortName = "Bar Property", Description = "A description about Bar.")]
	public int Bar { get; set; }

Actipro Software Support

The latest build of this product (v22.1.2) was released 1 month ago, which was before the next post in this thread.
Posted 8 days ago by Procam


for the localization, we do not use such an approach with .NET string resources.

Instead of that, our XAML uses a converter with such code:

BindingOperations.SetBinding(textBlock, TextBlock.TextProperty, new Binding("Value") { Source = new TranslationData(resultText, null) });

It means the Dependency property (e.g. Text) of the Dependency object (e.g. TextBlock) is bound to the property 'Value' of object TranslationData (that implements INotifyPropertyChanged). When the language is changed, the PropertyChanged event of this property is invoked returning the desired translation from our excel file (repository of all translations, all languages).

Taking this into count, it seems I have to apply your clone/update proposal. Does it mean I have to re-template the whole Grids.xaml? Do you have some sample for me?

Anyways, it should be nice, as for PropertyEditor, to provide something similar also for CategoryEditor, something like this:


Thanks for you reply.

Posted 8 days ago by Actipro Software Support - Cleveland, OH, USA


You wouldn't have to clone all of the Grids XAML, just the PropertyGrid.DefaultCategoryItemContainerStyle default value, which is just 30-something lines long.

A third option is that you could override the TypeDescriptorFactory class with a MyTypeDescriptorFactory class of your own.  Then override its CreateCategoryModel method, which is passed the category name and you return a CategoryModel from it.  Here's the default logic:

protected virtual ICategoryModel CreateCategoryModel(string name, IDataFactoryRequest request) {
	return new CategoryModel(name);

You could apply your translation there instead.  Then set an instance of your custom MyTypeDescriptorFactory class to the PropertyGrid.DataFactory property.

Actipro Software Support

Add Comment

Please log in to a validated account to post comments.