From 0784b98c8e6abcb88c141135d4a9e9c04eaccd5d Mon Sep 17 00:00:00 2001 From: Troy Stanger Date: Mon, 12 Nov 2018 13:09:51 -0600 Subject: [PATCH] Resize and re-layout ViewCells when the parent ListView is resized. --- Ooui.Forms/Renderers/ListViewRenderer.cs | 28 +++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Ooui.Forms/Renderers/ListViewRenderer.cs b/Ooui.Forms/Renderers/ListViewRenderer.cs index 4c2f1ff..b97f9f0 100644 --- a/Ooui.Forms/Renderers/ListViewRenderer.cs +++ b/Ooui.Forms/Renderers/ListViewRenderer.cs @@ -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.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)