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

ListView/CollectionView faulty height calculation in Grid with multiple columns #21974

Open
JonasSuchy opened this issue Apr 22, 2024 · 2 comments
Labels
area-controls-listview ListView and TableView area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter layout-grid migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 platform/windows 🪟 t/bug Something isn't working
Milestone

Comments

@JonasSuchy
Copy link

Description

In a Grid with one RowDefinition with width = auto, and a second one with width = star, the height of the ListView (or CollectionView, maybe ScrollView too) is not calculated correctly on Windows and Android. The issue is not present using MAUI on iOS, and was not present on any platform in XF.

<Grid HeightRequest="500" WidthRequest="500" BackgroundColor="WhiteSmoke">
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>

    <ListView Grid.Row="0" x:Name="MyListView" />
    <Label Grid.Row="1" Text="This should be below the list" HeightRequest="50" />
</Grid>

In this example the ListView is always as big as the Grid containing the ListView, even though the Label has a height of 50 and the ListView should shrink to accommodate it. In this case the Label will usually be overlayed, so that the bottom part of the ListView is not visible. On Windows the ListView is sometimes visible, and the label is invisible instead.

Adding additional grid rows above or below the list contribute to the issue further.

In other constellations like:

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>

and

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>

the issue is not present.

With two ColumnDefinitions:
grafik

Without the second ColumnDefinition:
grafik

Steps to Reproduce

  1. Add a Grid to any MAUI page with the following Column- and RowDefinitions:
<Grid.RowDefinitions>
    <RowDefinition Height="*"/>
    <RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
  1. Add a ListView or CollectionView and set it as the first row and some other element in the second row:
        <ListView Grid.Row="1" x:Name="MyListView" />
        <Label Grid.Row="2" Text="This should be below the list" HeightRequest="50" />
  1. Add more Items to the ListView (or CollectionView) than can be displayed in the available space.
  2. Scroll all the way to the last element.

Observed behavior:
The last entry is not visible, even after scrolling all the way down.
grafik

Expected behavior:
The last entry is visible on the bottom of the ListView after scrolling all the way down:
grafik

Link to public reproduction project repository

No response

Version with bug

8.0.20 SR4

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows

Affected platform versions

Android 14, Windows 11-SDK 10.22621.0

Did you find any workaround?

No response

Relevant log output

No response

@JonasSuchy JonasSuchy added the t/bug Something isn't working label Apr 22, 2024
@jsuarezruiz jsuarezruiz added area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter area-controls-listview ListView and TableView layout-grid labels Apr 22, 2024
@samhouts samhouts added migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/windows 🪟 platform/android 🤖 labels Apr 22, 2024
@RoiChen001 RoiChen001 added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert and removed migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert labels May 27, 2024
@RoiChen001
Copy link
Collaborator

RoiChen001 commented May 27, 2024

Can repro this issue at Windows platform on the latest 17.11.0 Preview 1.0(8.0.14/8.0.21).
Sample project:
https://microsoft-my.sharepoint.com/:f:/p/v-chenda/EkSu1q7rujhGqedMO4IYIW0BvWYR-zthImO9EfLyL52Evw?e=QRTDlo
MainPage.xaml1.txt
MainPage.xaml.cs1.txt
BTW, I verified that this issue works fine on Xamarin.Android.

@mgr44
Copy link

mgr44 commented Jun 18, 2024

This issue is causing problems for my team as well. So far I have not found a work around other than setting the Auto row or column definitions to a set height, which isn't really a work around for us since we need auto sizing to properly size our grid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-listview ListView and TableView area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter layout-grid migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants