Stop Property Grid sorting

Grids for WPF Forum

Posted 3 months ago by Daniel Constantin - ModuleWorks GmbH
Version: 25.1.1
Avatar

Hi!

I have a property grid with PropertyModel s. Some of them has categories, other not. For some reason the PropertyModel s with categories are put above the ones without categories.

SortComparer="{x:Null}" did not worked also.

I want to not have any sorting.

Kind regards,

Daniel

[Modified 3 months ago]

Comments (3)

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

The PropertyGrid.SortComparer is what determines how items are sorted.  It flows down to the TypeDescriptorFactory.SortDataModels virtual method that uses the sort comparer, if available, to sort the child data models at each level.  Setting the SortComparer to null will effectively disable default sorting.

If I set PropertyGrid.SortComparer to null in our PropertyGrid Getting Started QuickStart, I see the Misc category (those properties without categories set) appearing first.  It could just be based on which property reflects first when sorting is disabled, that determines which category (its category) appears first.

If you would like to customize sorting behavior, you can create a class that inherits DataModelSortComparer, override the logic in that comparer's virtual methods, and set an instance of your class to PropertyGrid.SortComparer.


Actipro Software Support

Posted 1 month ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Hi!

For some reason I cannot make a grids:PropertyModel disabled. IsEnabled="False" does not seem to work.

I also tried setting the visibility but I could not managed to make it work.

Any advice would be appreciated.

Kind regards,

Daniel

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

Hello,

The PropertyModel class is used for explicit definitions of property models, meant to optionally support XAML bindings on its properties.  It ideally would have inherited DependencyObject, however due to limitations in WPF where XAML bindings on its properties wouldn't have worked with that base class, we had to have it inherit FrameworkElement instead.  The FrameworkElement base class adds the IsEnabled property but it is not part of the IPropertyModel interface.  Thus none of our built-in editors will look at IsEnabled.

You would want to set the PropertyModel.IsValueReadOnly property to true instead.  Our property editor controls bind to the PropertyModel.IsReadOnly value, which is a resolved result of IsHostReadOnly and IsValueReadOnly.


Actipro Software Support

The latest build of this product (v25.1.3) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.