diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2013-10-25 14:31:02 +0400 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2013-10-25 14:31:02 +0400 |
commit | 51b89a80410bd72c6dafce59d5ffc0bcfe4fb96f (patch) | |
tree | 92ed7f52669e81faca33f7d904b79c968f8d3e31 /Xwt.WPF | |
parent | 4b0970039983644acdecc85ff30699bc627a4bab (diff) |
[WPF] Widget allocation optimization
Box: Only measure the child widget when it is first added to the box.
Diffstat (limited to 'Xwt.WPF')
-rw-r--r-- | Xwt.WPF/Xwt.WPFBackend/BoxBackend.cs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Xwt.WPF/Xwt.WPFBackend/BoxBackend.cs b/Xwt.WPF/Xwt.WPFBackend/BoxBackend.cs index 688a01d0..a31a3e1a 100644 --- a/Xwt.WPF/Xwt.WPFBackend/BoxBackend.cs +++ b/Xwt.WPF/Xwt.WPFBackend/BoxBackend.cs @@ -120,11 +120,15 @@ namespace Xwt.WPFBackend // because WPF widgets my cache some measurement information based on the
// constraints provided in the last Measure call (which when calculating the
// preferred size is normally set to infinite.
- element.InvalidateMeasure ();
- element.Measure (new SW.Size (rects[i].Width, rects[i].Height));
-
- element.Arrange (rects[i].ToWpfRect ());
- element.UpdateLayout ();
+ var r = rects[i].WithPositiveSize ();
+ if (force) {
+ // Don't recalculate the size unless a relayout is being forced
+ element.InvalidateMeasure ();
+ element.Measure (new SW.Size (r.Width, r.Height));
+ }
+
+ element.Arrange (r.ToWpfRect ());
+ // element.UpdateLayout ();
}
}
}
|