From efdcd1195222caf1e60ee4f068df142ca0cf463a Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Fri, 24 May 2019 23:22:51 +0800 Subject: [PATCH] Part 9 of n --- src/Avalonia.Controls/DefinitionBase.cs | 1 + src/Avalonia.Controls/GridWPF.cs | 27 +++++++++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/Avalonia.Controls/DefinitionBase.cs b/src/Avalonia.Controls/DefinitionBase.cs index b25ae3ab59..f9a7fc648d 100644 --- a/src/Avalonia.Controls/DefinitionBase.cs +++ b/src/Avalonia.Controls/DefinitionBase.cs @@ -21,6 +21,7 @@ namespace Avalonia.Controls static DefinitionBase() { SharedSizeGroupProperty.Changed.AddClassHandler(OnSharedSizeGroupPropertyChanged); + BoundsProperty.Changed.AddClassHandler(OnUserSizePropertyChanged); } /// diff --git a/src/Avalonia.Controls/GridWPF.cs b/src/Avalonia.Controls/GridWPF.cs index c9397e2e20..e85fa1cdb0 100644 --- a/src/Avalonia.Controls/GridWPF.cs +++ b/src/Avalonia.Controls/GridWPF.cs @@ -80,11 +80,10 @@ namespace Avalonia.Controls /// public bool ShowGridLines { - get { return (CheckFlagsAnd(Flags.ShowGridLinesPropertyValue)); } + get { return GetValue(ShowGridLinesProperty); } set { SetValue(ShowGridLinesProperty, value); } } - /// /// Gets the value of the Column attached property for a control. /// @@ -186,7 +185,6 @@ namespace Avalonia.Controls { get { - if (_data == null) { _data = new ExtendedData(); } if (_columnDefinitions == null) { @@ -204,6 +202,9 @@ namespace Avalonia.Controls throw new NotSupportedException("Reassigning ColumnDefinitions not yet implemented."); } + if (_data == null) { _data = new ExtendedData(); } + + _columnDefinitions = value; _columnDefinitions.TrackItemPropertyChanged(_ => InvalidateMeasure()); _columnDefinitions.CollectionChanged += (_, __) => InvalidateMeasure(); @@ -217,8 +218,6 @@ namespace Avalonia.Controls { get { - if (_data == null) { _data = new ExtendedData(); } - if (_rowDefinitions == null) { RowDefinitions = new RowDefinitions(); @@ -234,12 +233,17 @@ namespace Avalonia.Controls throw new NotSupportedException("Reassigning RowDefinitions not yet implemented."); } + if (_data == null) { _data = new ExtendedData(); } + _rowDefinitions = value; _rowDefinitions.TrackItemPropertyChanged(_ => InvalidateMeasure()); _rowDefinitions.CollectionChanged += (_, __) => InvalidateMeasure(); } } + private bool rowColDefsEmpty => (RowDefinitions == null || RowDefinitions?.Count == 0 ) && + (ColumnDefinitions == null || ColumnDefinitions?.Count == 0); + /// /// Content measurement. /// @@ -255,7 +259,7 @@ namespace Avalonia.Controls ListenToNotifications = true; MeasureOverrideInProgress = true; - if (extData == null) + if (rowColDefsEmpty) { gridDesiredSize = new Size(); @@ -400,7 +404,7 @@ namespace Avalonia.Controls ArrangeOverrideInProgress = true; - if (_data == null) + if (rowColDefsEmpty) { for (int i = 0, count = Children.Count; i < count; ++i) { @@ -603,7 +607,7 @@ namespace Avalonia.Controls // clamp to not exceed beyond bottom side of the grid // row_span > 0 is guaranteed by property value validation callback cell.RowSpan = Math.Min(GetRowSpan(child), DefinitionsV.Length - cell.RowIndex); - + Debug.Assert(0 <= cell.ColumnIndex && cell.ColumnIndex < DefinitionsU.Length); Debug.Assert(0 <= cell.RowIndex && cell.RowIndex < DefinitionsV.Length); @@ -2275,8 +2279,6 @@ namespace Avalonia.Controls { grid.InvalidateVisual(); } - - grid.SetFlags((bool)e.NewValue, Flags.ShowGridLinesPropertyValue); } private static void OnCellAttachedPropertyChanged(Visual child, AvaloniaPropertyChangedEventArgs e) @@ -2590,11 +2592,6 @@ namespace Avalonia.Controls ValidDefinitionsVStructure = 0x00000002, ValidCellsStructure = 0x00000004, - // - // boolean properties state - // - ShowGridLinesPropertyValue = 0x00000100, // show grid lines ? - // // boolean flags //