Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackPanel in ScrollViewer : invalid visual descendant bounds after adding items (making vertical scrollbar appear) then removing items #9077

Open
JPDelprat opened this issue May 3, 2024 · 2 comments
Labels
Investigate Requires further investigation by the WPF team.

Comments

@JPDelprat
Copy link

Description

StackPanel in ScrollViewer : when adding items to StackPanel (to make vertical scrollbar appear than removing them), than removing some of them (which makes scrollbar disppear), VisualTreeHelper.GetDescendantBounds() provides an incorrect value, which corresponds to the vertical scrollbar height before removing items.

=> Several possible side effects. In my case, an OpacityMask was stretched.

Note : VisualTreeHelper.GetContentBounds is correct though.

Reproduction Steps

I have a StackPanel in a scrollviewer.

I add items to this StackPanel so that vertical scrollbar appears, than I remove some them (to make scrollbar disappear).
I do it programmatically (stackPanel.Children.Add/Remove).

VisualTreeHelper.GetDescendantBounds then gives an incorrect height for my stackPanel, which corresponds to the scrollbar height before I remove some items.

If I spy the track control inside the scrollbar, its actual height is the invalid one.

Expected behavior

VisualTreeHelper.GetDescendantBounds() should provide the real height

Actual behavior

VisualTreeHelper.GetDescendantBounds() provide the bad height (see above).

Regression?

No response

Known Workarounds

My issue was related to OpacityMask => I've forced the mask ViewPort height from my ScrollViewer ActualHeight.

Impact

No response

Configuration

No response

Other information

No response

@JPDelprat JPDelprat changed the title StackPanel in ScrollViewer : invalid visual bounds after adding items (making vertical scrollbar appear) then removing items StackPanel in ScrollViewer : invalid visual descendant bounds after adding items (making vertical scrollbar appear) then removing items May 3, 2024
@rchauhan18
Copy link
Contributor

@JPDelprat Can you provide a sample repro for this?

@rchauhan18 rchauhan18 added the 📭 waiting-author-feedback To request more information from author. label May 6, 2024
@JPDelprat
Copy link
Author

JPDelprat commented May 6, 2024

Here is a test program which reproduce the problem.

BadDescendantsBoundsAfterRemovingItems.zip

Step 1
image

Step2
image

@dotnet-policy-service dotnet-policy-service bot removed the 📭 waiting-author-feedback To request more information from author. label May 6, 2024
@singhashish-wpf singhashish-wpf added the Investigate Requires further investigation by the WPF team. label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate Requires further investigation by the WPF team.
Projects
None yet
Development

No branches or pull requests

3 participants