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

ItemsStackPanel with ListView does not layout items properly when horizontal scroll mode is enabled #9860

Open
w-ahmad opened this issue Jul 30, 2024 · 3 comments
Labels
area-Lists ListView, GridView, ListBox, etc bug Something isn't working team-Controls Issue for the Controls team

Comments

@w-ahmad
Copy link

w-ahmad commented Jul 30, 2024

Describe the bug

When horizontal scroll mode is enabled in a ListView with ItemsStackPanel, it does not measure and arrange item content correctly. This issue seems to occur only when the child or a descendant is a TextBlock whose desired width exceeds its set width. Replacing the ItemsStackPanel with a StackPanel resolves the issue, but at the cost of losing virtualization.

Steps to reproduce the bug

Add the code below to a new app and you'll be able to see the issue.

<ListView ScrollViewer.HorizontalScrollMode="Auto"
          ScrollViewer.HorizontalScrollBarVisibility="Auto">
    <Button Width="40">Click Me</Button>
    <Button Width="40">Click Me</Button>
    <Button Width="40">Click Me</Button>
</ListView>

image

Or here the simple app to demonstrate this issue. https://github.com/w-ahmad/ListViewLayoutIssue. You can increase value in NumberBox until the issue is gone.

Expected behavior

The item's content should be measured and arranged properly, as they are when horizontal scroll mode is disabled.
image

Screenshots

No response

NuGet package version

None

Windows version

No response

Additional context

No response

@w-ahmad w-ahmad added the bug Something isn't working label Jul 30, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jul 30, 2024
@JesseCol JesseCol added area-Lists ListView, GridView, ListBox, etc team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Aug 1, 2024
@RBrid
Copy link
Contributor

RBrid commented Aug 2, 2024

Thanks for your report. We'll investigate.

Maybe using the VirtualizingStackPanel is an option for you in the meantime?

    <ListView>
        <ListView.ItemsPanel>
            <ItemsPanelTemplate>
                <VirtualizingStackPanel/>
            </ItemsPanelTemplate>
        </ListView.ItemsPanel>

        <Button Width="40">Click Me</Button>
        <Button Width="40">Click Me</Button>
     </ListView>

@w-ahmad
Copy link
Author

w-ahmad commented Aug 3, 2024

Thank you for your response @RBrid.

The VirtualizingStackPanel is able resolve the issue I've described, but it's causing problems with the horizontal scrolling of the header in my custom control, WinUI.TableView. I haven't tested it with ListView yet, so the header issue might be specific to my control.

This issue is preventing me from releasing the next update for my control; hence, I'm considering a workaround for it by manually calculating the widths for cells (content). Although this workaround won't address the problem for nested contents, it could be a temporary solution until a fix is available. I would greatly appreciate it if your team could address this in the 1.6 release.

Video.Project.1.mp4

Header scrolling issue by using VirtualizingStackPanel

@w-ahmad
Copy link
Author

w-ahmad commented Sep 12, 2024

@RBrid could it be fixed in a servicing release please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Lists ListView, GridView, ListBox, etc bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

3 participants