Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle setting of DesiredSize in Measure implementations, rather than MeasureOverride #19794

Merged
merged 1 commit into from Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Controls/src/Core/ContentPage/ContentPage.cs
Expand Up @@ -70,8 +70,7 @@ internal override void OnControlTemplateChanged(ControlTemplate oldValue, Contro

protected override Size MeasureOverride(double widthConstraint, double heightConstraint)
{
DesiredSize = this.ComputeDesiredSize(widthConstraint, heightConstraint);
return DesiredSize;
return this.ComputeDesiredSize(widthConstraint, heightConstraint);
}

protected override Size ArrangeOverride(Rect bounds)
Expand Down
3 changes: 1 addition & 2 deletions src/Controls/src/Core/ContentPresenter.cs
Expand Up @@ -102,8 +102,7 @@ static async void OnContentChanged(BindableObject bindable, object oldValue, obj

protected override Size MeasureOverride(double widthConstraint, double heightConstraint)
{
DesiredSize = this.ComputeDesiredSize(widthConstraint, heightConstraint);
return DesiredSize;
return this.ComputeDesiredSize(widthConstraint, heightConstraint);
}

Size ICrossPlatformLayout.CrossPlatformMeasure(double widthConstraint, double heightConstraint)
Expand Down
6 changes: 3 additions & 3 deletions src/Controls/src/Core/Layout.cs
Expand Up @@ -236,14 +236,14 @@ protected virtual void OnChildMeasureInvalidated()

Size IView.Measure(double widthConstraint, double heightConstraint)
{
return MeasureOverride(widthConstraint, heightConstraint);
DesiredSize = MeasureOverride(widthConstraint, heightConstraint);
return DesiredSize;
}

protected override Size MeasureOverride(double widthConstraint, double heightConstraint)
{
var sansMargins = OnMeasure(widthConstraint, heightConstraint).Request;
DesiredSize = new Size(sansMargins.Width + Margin.HorizontalThickness, sansMargins.Height + Margin.VerticalThickness);
return DesiredSize;
return new Size(sansMargins.Width + Margin.HorizontalThickness, sansMargins.Height + Margin.VerticalThickness);
}

protected override void OnSizeAllocated(double width, double height)
Expand Down
3 changes: 1 addition & 2 deletions src/Controls/src/Core/ScrollView/ScrollView.cs
Expand Up @@ -441,8 +441,7 @@ void IScrollView.RequestScrollTo(double horizontalOffset, double verticalOffset,

protected override Size MeasureOverride(double widthConstraint, double heightConstraint)
{
DesiredSize = this.ComputeDesiredSize(widthConstraint, heightConstraint);
return DesiredSize;
return this.ComputeDesiredSize(widthConstraint, heightConstraint);
}

Size ICrossPlatformLayout.CrossPlatformMeasure(double widthConstraint, double heightConstraint)
Expand Down
1 change: 0 additions & 1 deletion src/Controls/src/Core/Shapes/Shape.cs
Expand Up @@ -430,7 +430,6 @@ protected override Size MeasureOverride(double widthConstraint, double heightCon
result.Height += StrokeThickness;
result.Width += StrokeThickness;

DesiredSize = result;
return result;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Controls/src/Core/TemplatedView/TemplatedView.cs
Expand Up @@ -120,8 +120,7 @@ public virtual ControlTemplate ResolveControlTemplate()

protected override Size MeasureOverride(double widthConstraint, double heightConstraint)
{
DesiredSize = this.ComputeDesiredSize(widthConstraint, heightConstraint);
return DesiredSize;
return this.ComputeDesiredSize(widthConstraint, heightConstraint);
}

Size ICrossPlatformLayout.CrossPlatformMeasure(double widthConstraint, double heightConstraint)
Expand Down
6 changes: 3 additions & 3 deletions src/Controls/src/Core/VisualElement/VisualElement.cs
Expand Up @@ -1847,7 +1847,8 @@ void IView.InvalidateArrange()
/// <inheritdoc/>
Size IView.Measure(double widthConstraint, double heightConstraint)
{
return MeasureOverride(widthConstraint, heightConstraint);
DesiredSize = MeasureOverride(widthConstraint, heightConstraint);
return DesiredSize;
}

/// <summary>
Expand All @@ -1859,8 +1860,7 @@ Size IView.Measure(double widthConstraint, double heightConstraint)
/// <returns>The requested size that an element wants in order to be displayed on the device.</returns>
protected virtual Size MeasureOverride(double widthConstraint, double heightConstraint)
{
DesiredSize = this.ComputeDesiredSize(widthConstraint, heightConstraint);
return DesiredSize;
return this.ComputeDesiredSize(widthConstraint, heightConstraint);
}

/// <inheritdoc/>
Expand Down