This project has moved and is read-only. For the latest updates, please go here.

Dynamic property attributes for PropertyGrid

Nov 15, 2012 at 11:08 PM

My application's text will be translated into multiple languages.  Therefore, I need to change the text of categories,  displaynames, and descriptions at runtime.  Is this possible?


Also, I have objects that can be specified if relative or absolute terms, depending on what is convenient to the user.  A single object has properties for both absolute and relative specification.  How can I control which properties are browsable, on an instance by instance basis?

Nov 16, 2012 at 4:31 AM

For multiple language support, you may find what you need in the Extended WPF Toolkit Plus. You can download a trial here:

In the sample app, look for the "Localization" sample under "PropertyGrid"

Nov 16, 2012 at 4:34 AM
Edited Nov 16, 2012 at 4:34 AM

concerning your browsable properties, you have 2 options.

1. Decorate non-browsable properties with this attribute:



2. Use the "PropertyGrid.PropertyDefinitions" collection to specify only the properties that you want to display and set the "AutoGenerateProperties" property to false.

Nov 17, 2012 at 4:56 AM
Edited Nov 17, 2012 at 5:12 AM

Here's what I came up with. The end result id the ability to control which properties are displayed with a dictionary of string arrays holding lists of property names.

In classes that can be inserted to propertygrid:


string[] descriptorArray1 = {"propertyA", "propertyB"}; //these strings are displayName 
string[] descriptorArray2 = {"propertyC", "propertyD"}; //attributes for different properties

public Class()
   propertyDescriptorDictionary = new Dictionary ();
   propertyDescriptorDictionary["descriptorArray1"] = descriptorArray1;
   propertyDescriptorDictionary["descriptorArray2"] = descriptorArray2;


In gui method loading objects into propertygrid:


foreach (string propertyName in object.PropertyDefinitionsDictionary[object.tag])
    PropertyDefinition pd = new PropertyDefinition();
    pd.Name = propertyName;
propertyGrid.SelectedObject =move;
creating objects that can be passed to propertygrid:
Class instance = new Class();

//logic to chose which properties to display

instance.tag =  "descriptorArray1";