xamarin/Xamarin.Forms

[iOS] Listview scrolled cells blank when using DataTemplateSelector

Aperta

#2009 aperta il 3 mar 2018

 (12 commenti) (0 reazioni) (0 assegnatari)C# (1926 fork)batch import
a/listviewe/6 :clock6:help wantedp/iOS 🍎t/bug :bug:up-for-grabs

Metriche repository

Star
 (5644 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

When using a ListView with a DataTemplateSelector, cells scrolled into view appear either partially or fully blank. The bound collections are still there, since clicking the blank cells brings up the correct detail page, but it seems the cached views have been disposed.

Bypassing the DataTemplateSelector and setting the ItemTemplate to a single DataTemplate fixes the problem (but you're stuck with the single DataTemplate). Also, you won't see the issue as long as you're viewing cells that are all resolved to the same DataTemplate. It's only when you start switching between templates that the cell contents start disappearing when scrolled into view.

Note: This problem only occurs on iOS platform. Everything works as expected on Android.

Steps to Reproduce

  1. Open any ContentPage with ListView that uses a DataTemplateSelector on iOS device or simulator
  2. Scroll Listview to show additional cells

Expected Behavior

New cells should scroll into view

Actual Behavior

Cells scrolling into view are either completely or partially blank

Basic Information

  • Version with issue: Xamarin Forms v2.5.0.280555
  • Last known good version: Unknown
  • IDE:Visual Studio 2017 v15.5.7, Xamarin v4.8.118
  • Platform Target Frameworks:
    • iOS: Xamarin.iOS SDK v11.6.1.4
  • Nuget Packages: N/A
  • Affected Devices: All

Attachments

  • Screenshot of two types of objects (HouseholdViewModel & ChildViewModel) that resolve to different DataTemplates, before and after scrolling
  • Sample ContentPage XAML and code behind of affected ListView iOS ListView DataTemplateSelector Bug.zip

Guida contributor