Skip to content

Commit

Permalink
Fixes System.Inavlid.Cast Exception in iOS.CollectionViewRenderer.
Browse files Browse the repository at this point in the history
For Details see issue roubachof#47 System.InvalidCastExceptionin CollectionViewRenderer
  • Loading branch information
meierhoeferjannis committed Dec 16, 2021
1 parent f5869a6 commit ae65c85
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Sharpnado.CollectionView.iOS/Renderers/CollectionViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,21 @@ private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs
return;
}

if (Control.NumberOfItemsInSection(0) == ((IList)_itemsSource).Count)
var count = 0;
if (_itemsSource is IList list)
{
count = list.Count;
}
else
{
var enumerator = _itemsSource.GetEnumerator();
while (enumerator.MoveNext())
{
count += 1;
}
}

if (Control.NumberOfItemsInSection(0) == count)
{
return;
}
Expand Down

0 comments on commit ae65c85

Please sign in to comment.