Bug 44525 - Xamarin.Forms Listview Row Height Does Not Update When Changing Content Size (such as label)
Summary: Xamarin.Forms Listview Row Height Does Not Update When Changing Content Size ...
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS (show other bugs)
Version: 2.2.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-09-20 14:50 UTC by Hakan
Modified: 2017-12-02 01:18 UTC (History)
12 users (show)

See Also:
Tags: ac
Is this bug a regression?: ---
Last known good build:

Test project (174.03 KB, application/zip)
2017-06-16 16:07 UTC, James Montemagno [MSFT]
RecycleElement after updating (50.70 KB, image/png)
2017-06-16 16:08 UTC, James Montemagno [MSFT]
RetainElement after adjusting text (64.28 KB, image/png)
2017-06-16 16:08 UTC, James Montemagno [MSFT]

Description Hakan 2016-09-20 14:50:47 UTC
I am using the code below as a custom cell in a listview. I am trying to use ForceUpdateSize() in order to update the cell of the listview whenever there is a change in the bound properties. The listview has the attribute HasUnevenRows="True". Still, when I change the name property to a long string at runtime (by using a button) in iOS, the row does not expand. But when string is long in the beginning of the application, the row has enough space to show the whole string. In Android, it seems to work fine even without the ForceUpdateSize() call. What should be done to update the height of the row to adapt to the changing content in iOS?

public class CustomCell : ViewCell
    public CustomCell()
        Label age = new Label();
        Label name = new Label();
        StackLayout cellWrapper = new StackLayout();

        age.SetBinding(Label.TextProperty, "Age");
        name.SetBinding(Label.TextProperty, "Name");

        age.PropertyChanged += UpdateCell;
        name.PropertyChanged += UpdateCell;


        View = cellWrapper;

    void UpdateCell(object sender, EventArgs e)

Comment 1 Samantha Houts [MSFT] 2016-09-28 16:48:55 UTC
Thank you for taking the time to submit the bug. We tried to reproduce the issue you reported but were unable given the description. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue, we would very much appreciate it.  
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d  

Warm regards, 
Xamarin Forms Team
Comment 2 Hakan 2016-09-29 21:29:21 UTC

You can reach the sample project following the link below:

When you start the application on iPhone and click "Change Name" button, you will see that the new name label for the first row will be changed and this long name will not fit in. As you scroll down and up again, you will see the row heigth increased in order to show the whole label. (I think this is due to row recycling)

Best regards.
Comment 3 Samantha Houts [MSFT] 2016-09-30 18:20:43 UTC
Aha! Yes, I see the issue when the ListView uses RecycleElement. That was the missing piece. Thank you!
Comment 4 Hakan 2016-09-30 20:12:59 UTC
You're welcome. Row height adjusts when the cell is recycled but not when the bound data changes. And ForceUpdateSize() and such does not seem to help.

It seems to be an important issue actually but I cannot change the "importance" field of the bug. Would you consider prioritizing it? 

By the way, I am not familiar with the bug fixing process of Xamarin. Does a bug like this usually get fixed in a month or so?

Comment 5 Hakan 2016-10-21 01:04:01 UTC
Any update on this one?
Comment 6 Rui Marinho 2017-03-14 10:37:56 UTC
Should be fixed in 2.3.5-pre1
Comment 7 thomas 2017-04-20 09:37:04 UTC
Sounds much like mine https://bugzilla.xamarin.com/show_bug.cgi?id=53359

Which still exists in 2.3.5-pre
Comment 8 Hakan 2017-04-25 16:04:54 UTC
@Rui Marinho: I tested it with 2.3.5-pre1. The value is updated but now listview scrolling is totally broken in a weird way. Have you tested it with the sample project I uploaded to Dropbox and shared the link previously?
Comment 9 James Montemagno [MSFT] 2017-06-16 16:07:20 UTC
I tested this against 2.3.5-pre3:

1.) There is no need for a custom cell at all as it doesn't do anything
2.) Bug: If set to RetainElement the new text is shown, but the image is not resized at all until you scroll down and scroll back up it is resized correct.
3.) Bug: if set to it to RecycleElement then it doesn't resize at first and you can't see the rest of the text, but as soon as you scroll down and up it is resized correct.

I have attached screenshots and new test project.
Comment 10 James Montemagno [MSFT] 2017-06-16 16:07:42 UTC
Created attachment 22949 [details]
Test project
Comment 11 James Montemagno [MSFT] 2017-06-16 16:08:10 UTC
Created attachment 22951 [details]
RecycleElement after updating
Comment 12 James Montemagno [MSFT] 2017-06-16 16:08:35 UTC
Created attachment 22952 [details]
RetainElement after adjusting text
Comment 13 Alan Homan 2017-09-22 18:42:28 UTC
Is there a target build to address this iOS issue?  I have tried the latest Xamarin.Forms and with RetainElement, RecycleElement, and RecycleElementAndDataTemplate and in all cases the cell does not resize when text is added.  The only way to see the new text is to scroll down or rotate which most users won't figure out on their own.  My app is in production and I have been waiting a few months for a fix. Thank for your attention to this matter.
Comment 14 Hakan 2017-12-02 01:18:42 UTC
Any update on this one? I also reported another bug on the subject of RecycleElement: Bug 60952. RecycleElement feature seems to be very buggy but it is also necessary for smooth scrolling in a lot cases other than the simplest: see Bug 60950.

Listview is a vital component of this platform and these issues seem to be ignored by Xamarin as even this bug alone is not fixed since almost one year and three months. Other than the ones I reported, there seem to be other bugs reported about this. I believe RecycleElement bugs should be prioritized.

Note You need to log in before you can comment on or make changes to this bug.