Collapsing a category resets invalid values

Grids for WPF Forum

Posted 7 years ago by rex hui
Version: 17.1.0652
Platform: .NET 4.7
Environment: Windows 10 (64-bit)

Run the PropertyGrid QuickStarts (Data Validation)

Enter an invalid value for BusinessLogic1

Click somewhere else, so you can see the red border on BusinessLogic1

Collapse category Custom Business Logic

Expand Custom Business Logic

the invalid value is reset to 0

Comments (2)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Rex,

Yes that is because if you enter -1 as a value there, it is invalid and doesn't get pushed down to the property model's Value setter.  The PositiveInt32ValidationRule instance prevents it from ever getting past the Binding.  Thus the value only remains solely in the TextBox control there.

When you collapse the category, you are removing the UI elements of the contained properties (including that TextBox).  Thus the UI is getting created again as you re-expand the category and the new TextBox no longer has that state.  

To work around this, you could validate another way, or you could maybe prevent categories from being collapsible.  I don't think there are any other changes we could make to help with this particular scenario.

Actipro Software Support

Posted 7 years ago by rex hui

I understand now. Thank you!

The latest build of this product (v24.1.2) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.