Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 30711e1

Browse files
kingces95PureWeen
authored andcommitted
Allocate prototypical view for RetainElement (#1226)
1 parent 9091419 commit 30711e1

File tree

4 files changed

+21
-84664
lines changed

4 files changed

+21
-84664
lines changed

Xamarin.Forms.Core/TemplatedItemsList.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,19 @@ public DataTemplate SelectDataTemplate(object item)
529529
return ItemTemplate.SelectDataTemplate(item, _itemsView);
530530
}
531531

532-
public TItem CreateContent(int index, object item, bool insert = false)
532+
public TItem ActivateContent(int index, object item)
533533
{
534534
TItem content = ItemTemplate != null ? (TItem)ItemTemplate.CreateContent(item, _itemsView) : _itemsView.CreateDefault(item);
535535

536536
content = UpdateContent(content, index, item);
537537

538+
return content;
539+
}
540+
541+
public TItem CreateContent(int index, object item, bool insert = false)
542+
{
543+
var content = ActivateContent(index, item);
544+
538545
if ((CachingStrategy & ListViewCachingStrategy.RecycleElement) != 0)
539546
return content;
540547

Xamarin.Forms.Platform.iOS/Renderers/ListViewRenderer.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -678,16 +678,7 @@ internal nfloat GetEstimatedRowHeight(UITableView table)
678678
}
679679

680680
// We're going to base our estimate off of the first cell
681-
var isGroupingEnabled = List.IsGroupingEnabled;
682-
683-
if (isGroupingEnabled)
684-
templatedItems = templatedItems.GetGroup(0);
685-
686-
object item = null;
687-
if (templatedItems == null || templatedItems.ListProxy.TryGetValue(0, out item) == false)
688-
return DefaultRowHeight;
689-
690-
var firstCell = templatedItems.ActivateContent(0, item);
681+
var firstCell = templatedItems.ActivateContent(0, templatedItems.ListProxy[0]);
691682

692683
// Let's skip this optimization for grouped lists. It will likely cause more trouble than it's worth.
693684
if (firstCell?.Height > 0 && !isGroupingEnabled)
@@ -778,7 +769,8 @@ internal nfloat CalculateHeightForCell(UITableView tableView, Cell cell)
778769
// Let the EstimatedHeight method know to use this value.
779770
// Much more efficient than checking the value each time.
780771
//_useEstimatedRowHeight = true;
781-
return (nfloat)req.Request.Height;
772+
var height = (nfloat)req.Request.Height;
773+
return height > 1 ? height : DefaultRowHeight;
782774
}
783775

784776
var renderHeight = cell.RenderHeight;

0 commit comments

Comments
 (0)