xamarin/Xamarin.Forms

[iOS] DataTemplateSelector doesn't work when an item is re-created in code-behind

开放

#7,836 创建于 2019年10月5日

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

仓库指标

星标
 (5,644 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Description

This works in ListView but not CollectionView. When a template selector is used (in this case with two different data templates) and a button click clears StackLayout children and adds a new view, CollectionView renders items in wrong positions.

Steps to Reproduce

  1. Run repro.
  2. Scroll to item 49.
  3. Click the "Clear" button
  4. Observe that the scroll position changes and there are multiple items with the new "Cleared at timestamp" view.
  5. Comment out Items.Add(new Model1())
  6. Re-run the test.
  7. Observe that the issue does not happen this time.

Expected Behavior

Code-behind changes should not confuse the CollectionView when a DataTemplateSelector is used.

Basic Information

  • Version with issue: 4.4.0.1211-nightly
  • Last known good version: N/A
  • IDE: VS2019
  • Affected Devices: XS

Screenshots

file (1)

Reproduction Link

App100.zip

贡献者指南