The code I have looks like this:
<ListView.Header>
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<StackLayout Padding="10,35,10,10" Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<local:ExtLabel ExtStyleId="Body" Text="Custom body Label"></local:ExtLabel>
<local:ExtLabel ExtStyleId="Header" Text="Custom hdr Label"></local:ExtLabel>
</StackLayout>
</StackLayout>
</ListView.Header>
Would it be possible to implement this with a <Grid>
and does the <Grid>
offer more flexibility than <StackLayout>
?
I think you might want to have a look at this excellent blog post about this. The source is an employee from Xamarin, even more so, one of the founders of Forms.
A few of the bullets in reference to Layouts:
DO NOT use a
StackLayout
to host a single child.DO NOT use a
Grid
when aStackLayout
suffices.DO NOT use multiple
StackLayout
s when aGrid
suffices.DO use a
Grid
to achieve layering.
In regard to looks, you could achieve the same with both. In regard to performance, take a look at the full blog post (and these rules) to decide what is the better option.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.