xamarin/Xamarin.Forms

[iOS] Listview scrolled cells blank when using DataTemplateSelector

开放

#2,009 创建于 2018年3月3日

 (12 条评论) (0 个反应) (0 位负责人)C# (1,926 个派生)batch import
a/listviewe/6 :clock6:help wantedp/iOS 🍎t/bug :bug:up-for-grabs

仓库指标

星标
 (5,644 个星标)
PR 合并指标
 (30 天内没有已合并 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

贡献者指南