[PropertyGrid][Dynamic Properties]Scrollbar behaves strangely

Grids for WPF Forum

Posted 7 months ago by Yuki
Version: 22.1.0
Avatar

Hello,

I'm developing based on "Dynamic Properties" sample. 

However, scrollbar sometimes behaves strangely.

Would you please tell me how to solve it?

You can see the behavior by changing "Dynamic Properties" sample as the following.

1. Change DisplayOutput.cs

  • Add 20 properties before "Target".
  • Change initial value of "target" to "DisplayTarget.Pane".
    • private DisplayTarget target = DisplayTarget.Pane;

2. Start Sample Browser and show Dynamic Properties.

3. Move scrollbar of PropertyGrid downward.

 ⇒Scrollbar length will change.

Comments (3)

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

Hello,

I added 20 properties right before Target and changed the default value of Target to Pane.  I then went to the sample and grabbed the ScrollBar thumb to drag downward but didn't see any issues.  I also tried going back to the sample and clicking the down arrow button of the ScrollBar and didn't see any issues.

Is there a step missing in the instructions above?  Can you add more detail?


Actipro Software Support

Posted 7 months ago by Yuki
Avatar

Hello,

Thank you for confirming.

Would you please try it again by below additional step?

  • Change GetPropertyVisibility()
    public bool GetPropertyVisibility(string propertyName) {
      switch (propertyName) {
        case "ScreenProfile":
        case "Orientation":
        case "Height":  // Add
        case "Width":   // Add
        case "Location":  // Add
          return (this.Target == DisplayTarget.Screen);
        default:
          return true;
      }
    }
  • Start Browser Sample and minimize window size by right bottom handle


It seems that GetPropertyVisibility() is called for only displayed property.

When Dynamic Properties sample is displayed, it is not called for "Target" property.

When scroll and "Target" property is displayed, it is called and scrollbar length will be longer.

[Modified 7 months ago]

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

Hello,

What this sample is doing is using a custom Style in the MainControl.xaml with a Setter for the PropertyGridItem.Visibility (based on the IsVisible property).  The code in WPF's ItemsControl will only apply the Style to realized PropertyGridItem containers.  That's why you saw GetPropertyVisibility only getting called for displayed properties, as it is called by the IsVisible property, which is only hit by that Style.

Now back on the ScrollBar.  It is using logic scrolling by default, meaning it has one scroll unit for each item in the control.  Due to how this sample works with setting item visibility, even the hidden items are still technically in the control.  It's just that their PropertyGridItem container is not visible to us.  But the ScrollBar doesn't realize that so it's reserving scroll units for those items.

I believe you can work around the logical scrolling issue by setting ScrollViewer.CanContentScroll="False" on the PropertyGrid.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.