Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] ListView Group Header Height Doesn't Autosize to Content #8662

Open
foehammer88 opened this issue Nov 26, 2019 · 7 comments
Open

[Bug] ListView Group Header Height Doesn't Autosize to Content #8662

foehammer88 opened this issue Nov 26, 2019 · 7 comments
Labels
a/listview Problems with the ListView/TableView e/4 🕓 4 m/high impact ⬛ p/iOS 🍎 t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!

Comments

@foehammer88
Copy link

foehammer88 commented Nov 26, 2019

Description

ListView Group Header height doesn't autosize to content. Unlike ListView cells and Headers, that auto size their heights to content, ListView Group Headers do not auto size, thus causing manual calculations of label height and sizes to set the height, which introduces bugs on various platforms and device sizes.

Steps to Reproduce

  1. Create a Sample project with a ListView and data source
  2. Make ListView data source support Item Groups
  3. Populate Groups with Items, where at least one Group title is very long
  4. Bind the data in ListView XAML

Expected Behavior

ListView Group Headers should auto size to content and not have any adverse visual artifacts.

Actual Behavior

ListView Group Header height stays constant and label/content spills out beneath the Group Header

Basic Information

  • Version with issue: 4.3.0.991211
  • Last known good version: ?
  • IDE: Visual Studio for Mac 8.3.10 (build 2)
  • Platform Target Frameworks:
    • iOS: iOS 13.2.2
    • Android: 10.0
  • Nuget Packages:
    • Xamarin.Forms 4.3.0.991211
    • Xamarin.Essentials 1.3.1
  • Affected Devices:
    • iPhone
    • Android

Screenshots

image

Reproduction Link

ListViewGroupHeaderHeightIssueProject.zip

@foehammer88 foehammer88 added s/unverified New report that has yet to be verified t/bug 🐛 labels Nov 26, 2019
@pauldipietro pauldipietro added this to New in Triage Nov 26, 2019
@nbevans
Copy link

nbevans commented Nov 26, 2019

Duplicate of #3769 (comment)

Fix proposed in here but not dealt with by XF team yet.

PS: It only affects iOS (out of the main 3 platforms). We had no issues getting group headings to properly size on Android or UWP.

@samhouts samhouts added a/listview Problems with the ListView/TableView p/iOS 🍎 labels Nov 26, 2019
@PureWeen
Copy link
Contributor

PureWeen commented Dec 6, 2019

@foehammer88 @nbevans have you tried this with CollectionView?

I tried the attached sample and it looks like the group header sizes correctly

@PureWeen PureWeen added e/4 🕓 4 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! and removed s/unverified New report that has yet to be verified labels Dec 6, 2019
@PureWeen PureWeen moved this from New to Ready For Work in Triage Dec 6, 2019
@samhouts samhouts added this to To do in iOS Ready For Work Dec 6, 2019
@samhouts samhouts removed this from Ready For Work in Triage Dec 6, 2019
@nielscup
Copy link

nielscup commented Feb 20, 2020

Same issue here (Xamarin.Forms 4.2.0.778463): groupHeader does not auto size on iOS, Android works fine. Also when visibility of the view inside the groupHeader is set to false, the groupHeader still takes up the original space on iOS.

@nbevans
Copy link

nbevans commented Jun 29, 2020

@foehammer88 @nbevans have you tried this with CollectionView?

I tried the attached sample and it looks like the group header sizes correctly

@PureWeen No I haven't tried CollectionView - but a lot of codebases are still using ListView.

@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 14, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@Jeanjean
Copy link

Jeanjean commented Jul 6, 2021

The following workaround worked for me:

public class GroupHeaderCell : ViewCell
{
    public GroupHeaderCell()
    {
        StackLayout layout = new StackLayout
        {
            Padding = 16,
            Children =
            {
                new Label { Text = "Header Title" },
                new Label { Text = "Some dynamic description of unknown rendered height" }
            }
        };
        layout.SizeChanged += (object sender, EventArgs e) =>
        {
            Height = layout.Height;
            ForceUpdateSize();
        };

        View = new StackLayout
        {
            Children = {
                layout
            }
        };
    }
}

It uses the Layout's OnSizeChanged event, but to allow the StackLayout to properly autosize inside a ViewCell it needs to be wrapped in an outer StackLayout. Also the ListView's HasUnevenRows should be set to true.

@EnglishDave
Copy link

This is STILL a problem. I know that the team's focus is on MAUI, but we were promised quality improvement updates. Come on, this has been open for almost 2 years.

@eli191
Copy link

eli191 commented Dec 14, 2022

Still got this crash today in release only, with MAUI and .NET 7.
In XAML cross platform view, I put a StackLayout around my ListView and set HasUnevenRows to True following @Jeanjean recommendation, now I avoid the crash but still my list is empty, when it is not in debug.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/listview Problems with the ListView/TableView e/4 🕓 4 m/high impact ⬛ p/iOS 🍎 t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!
Projects
Development

No branches or pull requests

8 participants