This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 44525 - Xamarin.Forms Listview Row Height Does Not Adapt In iOS
Summary: Xamarin.Forms Listview Row Height Does Not Adapt In iOS
Status: REOPENED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS (show other bugs)
Version: 2.2.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-09-20 14:50 UTC by Hakan
Modified: 2017-04-27 07:36 UTC (History)
8 users (show)

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


Attachments

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;

        cellWrapper.Children.Add(age);
        cellWrapper.Children.Add(name);

        View = cellWrapper;
    }


    void UpdateCell(object sender, EventArgs e)
    {
        ForceUpdateSize();
    }

}
Comment 1 Samantha Houts 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
Hello,

You can reach the sample project following the link below:
https://www.dropbox.com/s/lds6g8p2tq3cvqy/iOSListviewProblem.7z?dl=0

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 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?

Regards.
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?

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