dotnet / dotnet/wpf

Virtualized ListBox doesn't layout its items correctly if they have right "aligned" controls

Open
#8,824 2 comments 1 reaction 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

Right-docked controls are being hidden when in horizontally stretched list box items of a virtualized list box.
Seems like the layout isn't being re-evaluated after scrolling.

### Reproduction Steps

1. Build and run the attached WPF project. It launches a small window containing a virtualizing list box where each item has a left-docked TextBlock with text trimming and a right-docked button.
2. Using the vertical scroll bar click in the bottom gutter to page down once.
3. Then using the right hand edge of the application Window, reduce the width until the text of the line "six million nine hundred" starts being trimmed (character ellipses).
[App.zip](https://github.com/dotnet/wpf/files/14327448/App.zip)

### Expected behavior

The button "Click!" should continue to right-docked and should not be clipped no matter the width of the list box.
image

### Actual behavior

The button "Click!" gets clipped incorrectly
image

### Regression?

_No response_

### Known Workarounds

There doesn't appears to be a coding workaround that I could find. I tried swapping the item's data template from a DockPanel to a Grid, but it still had the problem. Tried invalidating measure and arrange when size changed too but no good.

So while this bug will still occur the user might be able to workaround it by scrolling vertically by a page and then returning (which actually performs the arrangement properly - see the screenshot in the "Expected Behavior" section); or resizing the width to make it wide again (although resizing may not be practical in some circumstances). But it happening at all is very undesirable.

### Impact

This bug hides parts of the UI unexpectedly and there is no simple code workaround.

### Configuration

Reproduced in .NET 6 and .NET 8
Windows 11
x64

### 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.