Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XamarinForms - Grid vs nested Stacklayouts - PERFORMANCE sweet spot

Considering performance - where is the sweet spot between grid and nested stacklayouts?

How many "levels of nesting" StackLayout makes it more efficient to use Grid?

Is the example below (3 levels of StackLayout nesting) good practice, or should one use Grid instead?

<StackLayout>
    <StackLayout>
        <StackLayout>
            <Label>...text...</Label>
        </StackLayout>
        <StackLayout>
            <Label>...text...</Label>
        </StackLayout>
    </StackLayout>
    <StackLayout>
        <StackLayout>
            <Label>...text...</Label>
        </StackLayout>
        <StackLayout>
            <Label>...text...</Label>
        </StackLayout>
    </StackLayout>
</StackLayout>
like image 349
PaxForce Avatar asked Mar 09 '23 10:03

PaxForce


1 Answers

You should use Grid. There's a lot of common mistakes we make when using Xamarin.Forms. Fortunately, I found this article and video that help me a lot. One of the points on it is exactly an advice about your question:

don't attempt to reproduce the appearance of a specific layout by using combinations of other layouts

This is exemplified by Grid x nested StackLayouts.

I hope it helps you too.

like image 131
Diego Rafael Souza Avatar answered Apr 27 '23 17:04

Diego Rafael Souza