wpftoolkit icon indicating copy to clipboard operation
wpftoolkit copied to clipboard

PropertyGrid - default ordering of properties should be declaration order, not alphabetical

Open billw2012 opened this issue 3 years ago • 7 comments

I have already ordered my properties in a logical manner in my class declarations, having to add PropertyOrder(n) to each one, and then update large sections of them every time I add a new property is somewhat painful. Instead, either the default should just be declaration order, or there should be an object or category level attribute that will specify to use declaration order. I looked at implementing this myself, but it appears somewhat complicated. If you have suggestions on how best to do it, then I will make a PR.

billw2012 avatar Jul 27 '21 19:07 billw2012

By default, a PropertyGrid should display its properties in alphabetical order to find them easily. If this is not the wanted behavior, The PropertyOrder attribute exists and can be placed for each Property.

In v4.3 you will be able to use a new property on the PropertyGrid to use (or not) the alphabetical display of properties inside a category. When false, the declaration order of the properties on the selected object will try to be respected.

Thank you.

XceedBoucherS avatar Aug 10 '21 20:08 XceedBoucherS

In v4.3 you will be able to use a new property on the PropertyGrid to use (or not) the alphabetical display of properties inside a

Why use a property for this instead of a new parameter for the CategoryOrderAttribute, or a new attribute CategoryPropertyOrderAttribute or something like this? Seems weird to split the configuration of behavior between instance properties on a specific property grid, and the attributes. If ordering of categories, and explicit property order is declared on the object model with attributes, why would this one ordering setting not be? Ideally I would suggest that all display preferences could be specified both on the object model, via attributes, and then overridden in a coherent manner on the specific property grid instance (e.g. using matched names, like CategoryPropertyOrderAttribute and CategoryPropertyOrderOverride or something).

The properties solution also suffers from the issue I raised here #1681.

billw2012 avatar Aug 10 '21 20:08 billw2012

Hi,

That is an interesting point of view. The v4.3 will be reviewed in order to not use a new property on the PropertyGrid, but instead use a new CategoryPropertyOrderAttribute to order the properties alphabetically or to follow the property declaration order.

Thank you.

XceedBoucherS avatar Aug 11 '21 16:08 XceedBoucherS

Please keep the possibility to use a property on the PropertyGrid when showing objects that are declared for other reasons than to be shown in PropertyGrid you should not be forced to go add an attribute to them

jhv2017kam avatar Sep 13 '21 09:09 jhv2017kam

Hi jhv2017kam, We will not remove any property on the PropertyGrid. We will simply add an attribute, which you can add to your class, in order to display the PropertyItems in the PropertyGrid, in the order of declaration from your class.

XceedBoucherS avatar Sep 17 '21 19:09 XceedBoucherS

As I understood you, you will only add this feature (keep order from declaration) as an attribute and not as a property but may be i am wrong that the property is already there?

jhv2017kam avatar Sep 20 '21 06:09 jhv2017kam

Currently, there are no property on the PropertyGrid which let you display the PropertyItems in the order of declaration. You need to manually set a PropertyOrder attribute over each of your property in order to order them the way you want in the PropertyGrid. This won't be necessary with this feature, in v4.3.

XceedBoucherS avatar Sep 21 '21 20:09 XceedBoucherS