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
Label age = new Label();
Label name = new Label();
StackLayout cellWrapper = new StackLayout();
age.PropertyChanged += UpdateCell;
name.PropertyChanged += UpdateCell;
View = cellWrapper;
void UpdateCell(object sender, EventArgs e)
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
Xamarin Forms Team
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)
Aha! Yes, I see the issue when the ListView uses RecycleElement. That was the missing piece. Thank you!
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?
Any update on this one?
Should be fixed in 2.3.5-pre1
Sounds much like mine https://bugzilla.xamarin.com/show_bug.cgi?id=53359
Which still exists in 2.3.5-pre
@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?
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.
Created attachment 22949 [details]
Created attachment 22951 [details]
RecycleElement after updating
Created attachment 22952 [details]
RetainElement after adjusting text
Is there a target build to address this iOS issue? I have tried the latest Xamarin.Forms 188.8.131.525-pre3 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.