dotnet / dotnet/wpf

ItemsControl with ItemsSource+VirtualizedStackPanel : bad scrollbar position after removing some items (different items heights)

Open
#9,080 2 comments 2 reactions 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

I have an ItemsControl with an ItemsSource and a VirtualizedStackPanel. Items have different heights.
I move the scrollbar to the bottom of ItemsControls.
I remove some items, so that scrollbar is still visible.

Resulting scrollbar position is invalid : only some of items which should be visible are on screen.

### Reproduction Steps

Use the provided sample project : start the application than click on "Click to make bug appear" button.
Both ItemsControl should be at the same scroll position, but they are not.

See attached picture.
![Bug](https://github.com/dotnet/wpf/assets/97788731/84415a3c-9faa-4849-b98c-f2edd416f01d)

Here is the sample project, to reproduce the problem.
[SampleProject.zip](https://github.com/dotnet/wpf/files/15209473/SampleProject.zip)

### Expected behavior

See the sample project : both itemsControl should be at the same scrolling position.

### Actual behavior

See the sample project : both itemsControl are not at the same scrolling position.

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.