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

Commit

Permalink
[Tizen] Fix CollectionView layout issue (#13988)
Browse files Browse the repository at this point in the history
* Add guard for invalid reference

* Fix CollectionView re-layout issue

* Fix adaptor for CollectionView
  • Loading branch information
sung-su committed May 18, 2021
1 parent b85c28e commit 713320f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ void OnAdaptorChanging()
(Adaptor as INotifyCollectionChanged).CollectionChanged -= OnCollectionChanged;
Adaptor.CollectionView = null;
}
_innerLayout.UnPackAll();
}

void OnAdaptorChanged()
Expand Down Expand Up @@ -613,7 +614,8 @@ void OnLayout()
Scroller.HorizontalStepSize = _layoutManager.GetScrollBlockSize();
Scroller.VerticalStepSize = _layoutManager.GetScrollBlockSize();
UpdateSnapPointsType(SnapPointsType);
Device.BeginInvokeOnMainThread(SendScrolledEvent);
if (Geometry.Width > 0 && Geometry.Height > 0 )
Device.BeginInvokeOnMainThread(SendScrolledEvent);
}
}

Expand Down
9 changes: 9 additions & 0 deletions Xamarin.Forms.Platform.Tizen/Renderers/ItemsViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ protected override void Dispose(bool disposing)
Element.ScrollToRequested -= OnScrollToRequest;
ItemsLayout.PropertyChanged -= OnLayoutPropertyChanged;
Control.Scrolled -= OnScrolled;
// Remove all child that created by ItemTemplate
foreach (var child in Element.LogicalChildren.ToList())
{
Element.RemoveLogicalChild(child);
}
}
if (_observableSource != null)
{
Expand Down Expand Up @@ -163,6 +168,10 @@ protected void UpdateAdaptor(bool initialize)
{
if (!initialize)
{
if (Control.Adaptor != null)
{
Control.Adaptor.ItemSelected -= OnItemSelectedFromUI;
}
if (Element.ItemsSource == null || !Element.ItemsSource.Cast<object>().Any())
{
Control.Adaptor = EmptyItemAdaptor.Create(Element);
Expand Down

0 comments on commit 713320f

Please sign in to comment.