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

Custom layout base on AbsoluteLayout will repeated measure many times #7060

Closed
xtuzy opened this issue May 12, 2022 · 4 comments
Closed

Custom layout base on AbsoluteLayout will repeated measure many times #7060

xtuzy opened this issue May 12, 2022 · 4 comments
Assignees
Labels
area/layout 🔲 StackLayout, GridLayout, ScrollView, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/windows 🪟 t/bug Something isn't working

Comments

@xtuzy
Copy link

xtuzy commented May 12, 2022

Description

I try to custom layout, it name ConstraintLayout.
First, i let it derive from Layout like AbsoluteLayout, but nothing show, i don't why.
Then, i ask help form Stackoverflow,see problem, someone say it need derive from AbsoluteLayout, so i change my code, see the changed result ConstraintLayout.Maui.cs, you can see the change.

When use AbsoluteLayout as base class, all control can show, but it will measure many times, when no control in ConstraintLayout, it need measure 6 times at start.
sharex-20220512103600

when two control in ConstraintLayout, it need measure many times.
sharex-20220512103833

I have made ConstraintLayout of WinUI, it just need 2 times at start.
sharex-20220512111916

I want know,

  1. how to use Layout, ILayout, LayoutManager,ILayoutManager to custom layout, someone say need use handler, but i don't need extra platform code, why also need use it, i search maui source code don't find AbsoluteLayoutHandler. what i miss?

Steps to Reproduce

  1. Run https://github.com/xtuzy/SharpConstraintLayout/tree/Modify

Version with bug

Release Candidate 3 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

Windows SDK 10.0.22000

Did you find any workaround?

No response

Relevant log output

No response

@xtuzy xtuzy added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels May 12, 2022
@jfversluis jfversluis added area/layout 🔲 StackLayout, GridLayout, ScrollView, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels May 12, 2022
@hartez hartez self-assigned this May 12, 2022
@hartez
Copy link
Contributor

hartez commented May 12, 2022

#7039 and #7049 may have fixed this. Noting it here so I can check.

@xtuzy
Copy link
Author

xtuzy commented May 14, 2022

I want die. Finally i found i just use incorrect Arrange method, View inherit form VisualElement and IView, they all have a Arrange method, i use it of VisualElement, so all control not show.

@xtuzy xtuzy closed this as completed May 14, 2022
@xtuzy xtuzy reopened this May 14, 2022
@xtuzy
Copy link
Author

xtuzy commented May 14, 2022

I write a simple customlayout, it also need measure 5 times


        static int index = 0;
        public override Size Measure(double widthConstraint, double heightConstraint)
        {
            Debug.WriteLine("Measure Times:" + index++);
            var availableSize = new Size(widthConstraint, heightConstraint);
            foreach (var child in (Layout as Layout).Children)
            {
                var childSize = child.Measure(widthConstraint, heightConstraint);
            }
            return availableSize;
        }

        public override Size ArrangeChildren(Rect bounds)
        {
            foreach (var child in (Layout as Layout).Children)
            {
                child.Arrange(new Rect(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2, child.DesiredSize.Width, child.DesiredSize.Height));
            }
            return bounds.Size;
        }

@xtuzy
Copy link
Author

xtuzy commented May 24, 2022

Today update to rc3, this problem have solved.

@xtuzy xtuzy closed this as completed May 24, 2022
@dotnet dotnet locked as resolved and limited conversation to collaborators Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/layout 🔲 StackLayout, GridLayout, ScrollView, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants