From e375b22686c766572c9918cf4b8185e5e6a4bd4d Mon Sep 17 00:00:00 2001 From: David Britch Date: Fri, 1 Nov 2024 10:37:51 +0000 Subject: [PATCH] Legacy measure methods deprecated (#2596) * Add xrefs. * Edits. --- docs/user-interface/layouts/custom.md | 2 +- docs/whats-new/dotnet-9.md | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/docs/user-interface/layouts/custom.md b/docs/user-interface/layouts/custom.md index 449c097a7..3c5f19fea 100644 --- a/docs/user-interface/layouts/custom.md +++ b/docs/user-interface/layouts/custom.md @@ -221,7 +221,7 @@ public override Size Measure(double widthConstraint, double heightConstraint) } ``` -The `Measure` method enumerates through all of the visible children in the layout, invoking the method on each child. It then returns the total size of the layout, taking into account the constraints and the values of the and properties. The method is called to ensure that the total size of the layout fits within its constraints. +The method enumerates through all of the visible children in the layout, invoking the method on each child. It then returns the total size of the layout, taking into account the constraints and the values of the and properties. The method is called to ensure that the total size of the layout fits within its constraints. > [!IMPORTANT] > When enumerating children in the implementation, skip any child whose property is set to . This ensures that the custom layout won't leave space for invisible children. diff --git a/docs/whats-new/dotnet-9.md b/docs/whats-new/dotnet-9.md index 984e19c4f..663c761a5 100644 --- a/docs/whats-new/dotnet-9.md +++ b/docs/whats-new/dotnet-9.md @@ -475,22 +475,20 @@ The `MainPage` property is retained for .NET MAUI 9, but will be completely remo ### Compatibility layouts -The compatibility layout classes in the `Microsoft.Maui.Controls.Compatibility` namespace have been obsoleted. +The compatibility layout classes in the namespace have been obsoleted. ### Legacy measure calls -The following `VisualElement` legacy measure methods have been obsoleted: +The following measure methods have been obsoleted: -- `protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)`. -- `public virtual SizeRequest Measure(double widthConstraint, double heightConstraint, MeasureFlags flags = MeasureFlags.None)` from `VisualElement`. +- +- -As a replacement, the following method has been introduced: +These are legacy measure methods that don't function correctly with .NET MAUI layout expectations. -- `public size Measure(double widthConstraint, double heightConstraint)` +As a replacement, the method has been introduced. This method returns the minimum size that an element needs in order to be displayed on a device. Margins are excluded from the measurement, but are returned with the size. This is the preferred method to call when measuring a view. -This `Measure` method returns the minimum size that an element needs in order to be displayed on a device. Margins are excluded from the measurement, but are returned with the size. This is the preferred method to call when measuring a view. - -In addition, the `Microsoft.Maui.SizeRequest` struct is obsoleted. Instead, `Microsoft.Maui.Size` should be used. +In addition, the struct is obsoleted. Instead, should be used. ## .NET for Android