0

I have a FlexLayout with a column direction. Within the FlexLayout, I've placed six StackLayouts each containing an image.

I need the six images to be centered within the StackLayouts, instead of now being display at the start.

<FlexLayout Direction="Column" VerticalOptions="Fill" HorizontalOptions="Fill">
    <StackLayout FlexLayout.Grow="1" BackgroundColor="#EBF6FD">
        <StackLayout.GestureRecognizers>
            <TapGestureRecognizer Command="{Binding TimeSheetCommand, Source={x:Reference page}}"></TapGestureRecognizer>
        </StackLayout.GestureRecognizers>

        <ImageButton VerticalOptions="Center" HorizontalOptions="Center"  BackgroundColor="Transparent" Source="timesheet.png" Command="{Binding TimeSheetCommand, Source={x:Reference page}}"></ImageButton>
        <Label VerticalOptions="Center" HorizontalOptions="Center" Text="{x:Static resources:Resources.TitleTimeSheet}" Style="{StaticResource primaryNormalTextStyle}" TextColor="#7CB4DD"></Label>
    </StackLayout>

    <StackLayout FlexLayout.Grow="1" BackgroundColor="#EBF6FD">
        <StackLayout.GestureRecognizers>
            <TapGestureRecognizer Command="{Binding TimeSheetCommand, Source={x:Reference page}}"></TapGestureRecognizer>
        </StackLayout.GestureRecognizers>

        <ImageButton VerticalOptions="Center" HorizontalOptions="Center"  BackgroundColor="Transparent" Source="timesheet.png" Command="{Binding TimeSheetCommand, Source={x:Reference page}}"></ImageButton>
        <Label VerticalOptions="Center" HorizontalOptions="Center"  Text="{x:Static resources:Resources.TitleTimeSheet}" Style="{StaticResource primaryNormalTextStyle}" TextColor="#7CB4DD"></Label>
    </StackLayout>

How can I center the items inside the StackLayout?

Ola Ström
  • 4,136
  • 5
  • 22
  • 41
LittleFunny
  • 8,155
  • 15
  • 87
  • 198

0 Answers0