RelativeLayout and dynamically loaded content in a ListView

So, I have a Custom ListView (class inherited from ListView) that had a custom data template (ViewCell). When the initial cell loads, everything is fine and elements are aligned correctly.

However, when some of the cells need to load content asynchronously from the server, the content is not laid out correctly. The newly loaded content (which is shown using the IsVisible property) is cut off at the bottom and the rest of the elements are pushed outside of the cell.

I've attached a sample project to demonstrate what I'm doing, and what's going wrong.

From the example, it seems like the RelativeLayout is updating correctly when IsVisible is changed, but the height of the cell isn't automatically updating. I've tried using the MessageCenter and ForceUpdateSize on the custom cell but it didn't seem to change anything, the method was being called but the cell height did not change.

If when the content has loaded (and is pushed out of the cell) you then scroll the list view, and scroll back up, the content is now all in view, which implies the ListView does know how to calculate the height of these elements when it needs to, but it doesn't seem that ForceUpdateSize works for this.

Does anybody have any ideas about what I might be doing wrong, or what I could do to correct this?

Answers

  • JakeBarrow.6981JakeBarrow.6981 USMember

    Does anyone have any ideas on this? I'm still getting the issue in the latest version of Xamarin and Xamarin Forms.

  • JulienRosenJulienRosen CAMember ✭✭✭✭

    I think you will want to call ForceUpdateSize on the cell after the content has changed.

Sign In or Register to comment.