Skip to content

ListView should support non-Stretch alignment modes #1133

Closed as not planned
Closed as not planned

Description

@davidjohnoliver

What would you like to be added:

Support for the following:

<ListView Margin="0,100,0,200"
		  HorizontalAlignment="Left"
		  ItemsSource="{Binding SampleTowns}"
		  Background="LightGreen" />

At present, the HorizontalAlignment will be ignored and the list will be laid out as if it were set to Stretch.

Why is this needed:

One important use case is to support virtualization within the ComboBox's dropdown (#556 and #555).

Notes:

This is particularly difficult for iOS under the ListView's current approach, where items are not measured until they're about to be displayed:
https://github.com/nventive/Uno/blob/576c71b4cdd007b7c9c97c7f8f34e89b4e1e80bd/src/Uno.UI/UI/Xaml/Controls/ListViewBase/ListViewBaseSource.iOS.cs#L811
The fix would be to materialize about-to-be-visible items earlier, which would solve several other problems (eg glitchy-looking item animations). POC: https://github.com/nventive/Uno/tree/dev/djo/listview-ios-prematerialize-poc

For which Platform:

  • iOS
  • Android
  • WebAssembly
  • Windows

Anything else we need to know?

Activity

  1. added
    kind/enhancement
    triage/untriaged
    on Jun 25, 2019
  2. added
    platform/android 🤖
    platform/ios 🍎
    platform/wasm 🌐
    and removed
    triage/untriaged
    on Jul 2, 2019
  3. davidjohnoliver commented on Jul 16, 2019

    @davidjohnoliver
    ContributorAuthor

    Implemented for WASM by #1134.

  4. added
    project/items 🧾
    and removed on Sep 21, 2020
  5. robloo commented on Dec 2, 2020

    @robloo
    Contributor

    Is there some confusion here about HorizontalAlignment vs HorizontalContentAlignment? Or is it really not possible to horizontally align a ListView to the left within its parent? (not talking about its items at all).

    If talking about the items, I also wonder how the item container style factors in to the discussion. In UWP, it's necessary to change the item container style by retemplating to change the alignment of items within a ListView.

  6. davidjohnoliver commented on Dec 3, 2020

    @davidjohnoliver
    ContributorAuthor

    @robloo It's really not possible to give a (vertical) ListView a horizontal alignment within its parent other than Stretch on Android and iOS. This issue is specifically talking about the alignment mode of the ListView itself, not the alignment mode applied to the item containers.

  7. robloo commented on Dec 3, 2020

    @robloo
    Contributor

    @davidjohnoliver Ok, I figured you didn't mistype it is just a very strange limitation. Seems like the layout system should be able to handle this case just the same as any other control. Regardless, I'll have to change how ListView is used in a few places but that won't be a major problem as those design changes was more-or-less required anyway due to screen size constraints.

  8. added
    difficulty/tbd
    on Feb 15, 2021
  9. added
    difficulty/challenging 🤯
    and removed
    difficulty/tbd
    on May 31, 2021
  10. github-actions commented on Jul 22, 2025

    @github-actions
    Contributor

    This issue has become stale with over 1 year of inactivity and will be closed in 10 days unless a comment is provided or the stale label is removed.

  11. added
    stale
    on Jul 22, 2025
  12. MartinZikmund commented on Jul 23, 2025

    @MartinZikmund
    Member

    Still relevant for Skia

  13. removed
    stale
    on Jul 23, 2025
  14. MartinZikmund commented on Apr 7, 2026

    @MartinZikmund
    Member

    Repro generator

    Runtime test(s) added in branch dev/mazi/repro/1133:

    • src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase.cs → When_ListView_HorizontalAlignment_Left_Sizes_To_Content

    ⚠️ The test(s) pass on current master (Skia Desktop) — HorizontalAlignment=Left is respected and the ListView does not stretch to fill the container. The original issue was reported for iOS and Android where the native layout path behaved differently. The branch is provided as a regression guard for the managed path and as a starting point for testing on native platforms.

  15. added
    native-only
    on Oct 14, 2026
  16. MartinZikmund commented on Nov 7, 2026

    @MartinZikmund
    Member

    Thank you for the report and the detailed notes.

    This issue was about the native iOS and Android ListView layout path, where items were measured lazily (ListViewBaseSource.iOS.cs) and HorizontalAlignment was ignored. In 7.0 the native renderers are removed and Skia renders the UI on every target, and that source file is no longer in the repository. A runtime test on the repro branch (When_ListView_HorizontalAlignment_Left_Sizes_To_Content) was also reported to pass on Skia Desktop, meaning the ListView honors HorizontalAlignment="Left" through the managed layout path. (That was reported earlier on the issue. We did not run it as part of this review.)

    Since the problem was specific to the removed native code path, we are closing this as not planned. If you still see a non-Stretch HorizontalAlignment being ignored on a ListView in 7.0, please open a new issue with a minimal repro and we will take a look.

    This was checked as part of an AI-assisted backlog review by reading the code, not by running it. If it looks wrong, please reply and we will take another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty/challenging 🤯has-repro-branchkind/enhancementnative-onlyplatform/android 🤖platform/ios 🍎platform/wasm 🌐project/items 🧾

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions