Ver código fonte

Merge pull request #2679 from AvaloniaUI/fixes/gridpslitter-fix-size-refresh

Invalidate when Row&ColumnDefinition's properties change
Wiesław Šoltés 6 anos atrás
pai
commit
8876d3a4e0

+ 27 - 6
src/Avalonia.Controls/ColumnDefinition.cs

@@ -62,8 +62,15 @@ namespace Avalonia.Controls
         /// </summary>
         public double MaxWidth
         {
-            get { return GetValue(MaxWidthProperty); }
-            set { SetValue(MaxWidthProperty, value); }
+            get
+            {
+                return GetValue(MaxWidthProperty);
+            }
+            set
+            {
+                Parent?.InvalidateMeasure();
+                SetValue(MaxWidthProperty, value);
+            }
         }
 
         /// <summary>
@@ -71,8 +78,15 @@ namespace Avalonia.Controls
         /// </summary>
         public double MinWidth
         {
-            get { return GetValue(MinWidthProperty); }
-            set { SetValue(MinWidthProperty, value); }
+            get
+            {
+                return GetValue(MinWidthProperty);
+            }
+            set
+            {
+                Parent?.InvalidateMeasure();
+                SetValue(MinWidthProperty, value);
+            }
         }
 
         /// <summary>
@@ -80,8 +94,15 @@ namespace Avalonia.Controls
         /// </summary>
         public GridLength Width
         {
-            get { return GetValue(WidthProperty); }
-            set { SetValue(WidthProperty, value); }
+            get
+            {
+                return GetValue(WidthProperty);
+            }
+            set
+            {
+                Parent?.InvalidateMeasure();
+                SetValue(WidthProperty, value);
+            }
         }
 
         internal override GridLength UserSizeValueCache => this.Width;

+ 31 - 10
src/Avalonia.Controls/RowDefinition.cs

@@ -29,7 +29,7 @@ namespace Avalonia.Controls
         /// <summary>
         /// Initializes a new instance of the <see cref="RowDefinition"/> class.
         /// </summary>
-        public RowDefinition() 
+        public RowDefinition()
         {
         }
 
@@ -38,7 +38,7 @@ namespace Avalonia.Controls
         /// </summary>
         /// <param name="value">The height of the row.</param>
         /// <param name="type">The height unit of the column.</param>
-        public RowDefinition(double value, GridUnitType type) 
+        public RowDefinition(double value, GridUnitType type)
         {
             Height = new GridLength(value, type);
         }
@@ -47,7 +47,7 @@ namespace Avalonia.Controls
         /// Initializes a new instance of the <see cref="RowDefinition"/> class.
         /// </summary>
         /// <param name="height">The height of the column.</param>
-        public RowDefinition(GridLength height) 
+        public RowDefinition(GridLength height)
         {
             Height = height;
         }
@@ -62,8 +62,15 @@ namespace Avalonia.Controls
         /// </summary>
         public double MaxHeight
         {
-            get { return GetValue(MaxHeightProperty); }
-            set { SetValue(MaxHeightProperty, value); }
+            get
+            {
+                return GetValue(MaxHeightProperty);
+            }
+            set
+            {
+                Parent?.InvalidateMeasure();
+                SetValue(MaxHeightProperty, value);
+            }
         }
 
         /// <summary>
@@ -71,8 +78,15 @@ namespace Avalonia.Controls
         /// </summary>
         public double MinHeight
         {
-            get { return GetValue(MinHeightProperty); }
-            set { SetValue(MinHeightProperty, value); }
+            get
+            {
+                return GetValue(MinHeightProperty);
+            }
+            set
+            {
+                Parent?.InvalidateMeasure();
+                SetValue(MinHeightProperty, value);
+            }
         }
 
         /// <summary>
@@ -80,12 +94,19 @@ namespace Avalonia.Controls
         /// </summary>
         public GridLength Height
         {
-            get { return GetValue(HeightProperty); }
-            set { SetValue(HeightProperty, value); }
+            get
+            {
+                return GetValue(HeightProperty);
+            }
+            set
+            {
+                Parent?.InvalidateMeasure();
+                SetValue(HeightProperty, value);
+            }
         }
 
         internal override GridLength UserSizeValueCache => this.Height;
         internal override double UserMinSizeValueCache => this.MinHeight;
         internal override double UserMaxSizeValueCache => this.MaxHeight;
     }
-}
+}