Resize and re-layout ViewCells when the parent ListView is resized.

This commit is contained in:
Troy Stanger 2018-11-12 13:09:51 -06:00
parent 1e5561c1a8
commit 0784b98c8e
1 changed files with 27 additions and 1 deletions

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Timers;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
using Ooui.Forms.Cells;
@ -14,6 +15,7 @@ namespace Ooui.Forms.Renderers
const int DefaultRowHeight = 44;
private bool _disposed;
IVisualElementRenderer _prototype;
Timer _timer;
int _rowHeight;
@ -68,7 +70,31 @@ namespace Ooui.Forms.Renderers
base.OnElementPropertyChanged (sender, e);
if (e.PropertyName == ItemsView<Cell>.ItemsSourceProperty.PropertyName)
UpdateItems ();
UpdateItems();
else if (e.PropertyName == Xamarin.Forms.ListView.RowHeightProperty.PropertyName)
{
UpdateRowHeight();
UpdateItems();
}
else if (e.PropertyName == VisualElement.WidthProperty.PropertyName)
{
if (_timer != null)
{
_timer.Stop();
}
else
{
_timer = new Timer();
_timer.Interval = 250;
_timer.Elapsed += delegate {
UpdateItems();
};
_timer.Enabled = true;
_timer.AutoReset = false;
}
_timer.Start();
}
}
protected override void Dispose (bool disposing)