Custom MAUI layout don't show any Control, but control have correct position and size,

562 Views Asked by At

I custom a layout name ConstraintLayout according to AbsoluteLayout in MAUI.

It like AbsoluteLayout have a LayoutManager class,i overrride Measure and ArrangeChildren method in this class.

It also have a ConstrainLayout class. public class ConstraintLayout : Layout, IConstraintLayout

Source Code at ConstraintLayout.Maui

I print control information, found control in layout have correct position and size, such as position of Entry at center of window. but nothing show at window.

I need set something at builder or Handler? i don't find doc about it.

1

There are 1 best solutions below

1
On BEST ANSWER

I see that AbsoluteLayout works via a LayoutManager.

Find AbsoluteLayout.cs. See its:

    protected override ILayoutManager CreateLayoutManager()

Do similar, but find AbsoluteLayoutManager.cs, and make a similar ConstraintLayoutManager that uses your constraint logic. Then your method in ConstraintLayout will be:

protected override ILayoutManager CreateLayoutManager()
{
    return new ConstraintLayoutManager(this);
}

NOTE: Don't do my (now deleted) comment's ConstraintLayout : AbsoluteLayout .... Go back to your original ConstraintLayout : Layout, IConstraintLayout.