Repository navigation
Description
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
Activity
[Android] [iOS] Devirtualize ComboBox
[Android] [iOS] Devirtualize ComboBox
[Android] [iOS] Devirtualize ComboBox
davidjohnoliver commentedon Jul 16, 2019
Implemented for WASM by #1134.
robloo commentedon Dec 2, 2020
Is there some confusion here about
HorizontalAlignmentvsHorizontalContentAlignment? 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.
davidjohnoliver commentedon Dec 3, 2020
@robloo It's really not possible to give a (vertical) ListView a horizontal alignment within its parent other than
Stretchon 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.robloo commentedon Dec 3, 2020
@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.
github-actions commentedon Jul 22, 2025
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.
MartinZikmund commentedon Jul 23, 2025
Still relevant for Skia
test: Reproduce ListView HorizontalAlignment non-Stretch sizing
MartinZikmund commentedon Apr 7, 2026
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_ContentHorizontalAlignment=Leftis 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.MartinZikmund commentedon Nov 7, 2026
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) andHorizontalAlignmentwas 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 honorsHorizontalAlignment="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
HorizontalAlignmentbeing 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.