From dec707f392d886c891cd7dcde64eafdfec036cd7 Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Tue, 10 Jan 2017 17:33:50 +0900 Subject: [PATCH] Fix ListView GroupCell bug - When ViewCell was used for GroupHeaderTemplate ItemTemplate was used to make reusable view - Make disable Reusable feature for GroupHeader - Add a internal API to get low level Item object Change-Id: I01d205a2070c813a170a6eb9aceab8f24bbdb092 --- Xamarin.Forms.Platform.Tizen/Cells/CellRenderer.cs | 19 +++++++++++++++---- .../Cells/ViewCellRenderer.cs | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Xamarin.Forms.Platform.Tizen/Cells/CellRenderer.cs b/Xamarin.Forms.Platform.Tizen/Cells/CellRenderer.cs index 449b6f3..9489901 100644 --- a/Xamarin.Forms.Platform.Tizen/Cells/CellRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Cells/CellRenderer.cs @@ -9,6 +9,8 @@ namespace Xamarin.Forms.Platform.Tizen const string _heightProperty = "Height"; readonly Dictionary> _realizedNativeViews = new Dictionary>(); + Native.ListView.ItemContext _currentItem; + protected CellRenderer(string style) { Class = new GenItemClass(style) @@ -109,15 +111,22 @@ namespace Xamarin.Forms.Platform.Tizen OnUnrealizedCell(cell); } + internal Native.ListView.ItemContext GetCurrentItem() + { + return _currentItem; + } + string GetText(object data, string part) { - var span = OnGetText((data as Native.ListView.ItemContext).Cell, part); + _currentItem = data as Native.ListView.ItemContext; + var span = OnGetText(_currentItem.Cell, part); return span != null ? ToNative(span).GetMarkupText() : null; } EvasObject GetContent(object data, string part) { - var cell = (data as Native.ListView.ItemContext).Cell; + _currentItem = data as Native.ListView.ItemContext; + var cell = _currentItem.Cell; EvasObject nativeView = OnGetContent(cell, part); UpdateRealizedView(cell, part, nativeView); return nativeView; @@ -125,7 +134,8 @@ namespace Xamarin.Forms.Platform.Tizen EvasObject ReusableContent(object data, string part, EvasObject old) { - var cell = (data as Native.ListView.ItemContext).Cell; + _currentItem = data as Native.ListView.ItemContext; + var cell = _currentItem.Cell; EvasObject nativeView = OnReusableContent(cell, part, old); UpdateRealizedView(cell, part, nativeView); return nativeView; @@ -148,7 +158,8 @@ namespace Xamarin.Forms.Platform.Tizen void ItemDeleted(object data) { - var cell = (data as Native.ListView.ItemContext).Cell; + _currentItem = data as Native.ListView.ItemContext; + var cell = _currentItem.Cell; _realizedNativeViews.Remove(cell); OnDeleted(cell); } diff --git a/Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs b/Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs index 564a1ef..bb17ec8 100644 --- a/Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Cells/ViewCellRenderer.cs @@ -38,7 +38,7 @@ namespace Xamarin.Forms.Platform.Tizen // It is a condition for reusable the cell if (listView != null && listView.HasUnevenRows == false && - !(listView.ItemTemplate is DataTemplateSelector)) + !(listView.ItemTemplate is DataTemplateSelector) && !GetCurrentItem().IsGroupItem) { return CreateReusableContent(viewCell); } -- 2.7.4