xamarin/Xamarin.Forms

[iOS] Listview scrolled cells blank when using DataTemplateSelector

オープン

#2,009 opened on 2018/03/03

 (12 件のコメント) (0 件のリアクション) (0 人の担当者)C# (1,926 件のフォーク)batch import
a/listviewe/6 :clock6:help wantedp/iOS 🍎t/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

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

コントリビューターガイド