Browse Source

Invalidate parent grid measure when Row/Col definition's height/width props change. Fixes #2664

pull/2679/head
Jumar Macato 7 years ago
parent
commit
561ae7f185
No known key found for this signature in database GPG Key ID: B19884DAC3A5BF3F
  1. 33
      src/Avalonia.Controls/ColumnDefinition.cs
  2. 41
      src/Avalonia.Controls/RowDefinition.cs

33
src/Avalonia.Controls/ColumnDefinition.cs

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

41
src/Avalonia.Controls/RowDefinition.cs

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

Loading…
Cancel
Save