VerticalOptions of a View inside a Vertically oriented StackLayout behavior explained in guides?

mshwfmshwf EGMember ✭✭✭

In the guides for "LayoutOptions": developer.xamarin.com/guides/xamarin-forms/user-interface/layouts/layout-options/#Alignment , I read this:

A StackLayout does not respect the Start, Center, End, and Fill LayoutOptions fields on child views that are in the same direction as the StackLayout orientation. Therefore, a vertically oriented StackLayout ignores the Start, Center, End, or Fill fields if they are set on the VerticalOptions properties of child views. Similarly, a horizontally oriented StackLayout ignores the Start, Center, End, or Fill fields if they are set on the HorizontalOptions properties of child views.

I don't understand what does "respect" mean here, I actually can change the VerticalOptions of a view inside a StackLayout of Orientation set to "Vertical" in a normal way, and I always make use of it!

Answers

  • CharwakaCharwaka INMember ✭✭✭✭✭

    @mshwf said:
    In the guides for "LayoutOptions": developer.xamarin.com/guides/xamarin-forms/user-interface/layouts/layout-options/#Alignment , I read this:

    A StackLayout does not respect the Start, Center, End, and Fill LayoutOptions fields on child views that are in the same direction as the StackLayout orientation. Therefore, a vertically oriented StackLayout ignores the Start, Center, End, or Fill fields if they are set on the VerticalOptions properties of child views. Similarly, a horizontally oriented StackLayout ignores the Start, Center, End, or Fill fields if they are set on the HorizontalOptions properties of child views.

    I don't understand what does "respect" mean here, I actually can change the VerticalOptions of a view inside a StackLayout of Orientation set to "Vertical" in a normal way, and I always make use of it!

    It says that it will ignore Start, Center, End, and Fill LayoutOptions Options although you set explicitly for items inside stacklayout.

  • mshwfmshwf EGMember ✭✭✭

    @Charwaka said:

    @mshwf said:
    In the guides for "LayoutOptions": developer.xamarin.com/guides/xamarin-forms/user-interface/layouts/layout-options/#Alignment , I read this:

    A StackLayout does not respect the Start, Center, End, and Fill LayoutOptions fields on child views that are in the same direction as the StackLayout orientation. Therefore, a vertically oriented StackLayout ignores the Start, Center, End, or Fill fields if they are set on the VerticalOptions properties of child views. Similarly, a horizontally oriented StackLayout ignores the Start, Center, End, or Fill fields if they are set on the HorizontalOptions properties of child views.

    I don't understand what does "respect" mean here, I actually can change the VerticalOptions of a view inside a StackLayout of Orientation set to "Vertical" in a normal way, and I always make use of it!

    It says that it will ignore Start, Center, End, and Fill LayoutOptions Options although you set explicitly for items inside stacklayout.

    No,it doesn't ignore them, have you tried it?

  • JohnHardmanJohnHardman GBUniversity mod

    @mshwf - By coincidence, I asked Xamarin to re-visit this just a few days ago. See https://forums.xamarin.com/discussion/comment/307416#Comment_307416

  • CharwakaCharwaka INMember ✭✭✭✭✭
    edited November 2017

    Hi @mshwf

    see for vertical StackLayout

     <StackLayout>
                    <Label Grid.Row="0" Text="Charwaka" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="24" FontAttributes="Bold" BackgroundColor="LightGray"
                       TextColor="CadetBlue" HorizontalOptions="Start" />
                    <Label Grid.Row="0" Text="Charwaka" HorizontalOptions="Center" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="24" FontAttributes="Bold" BackgroundColor="LightGray"
                       TextColor="CadetBlue" />
                    <Label Grid.Row="0" Text="Charwaka" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="24" FontAttributes="Bold" BackgroundColor="LightGray"
                       TextColor="CadetBlue" HorizontalOptions="End" />
                </StackLayout>
    

    See for Horizontal Layout Same code I just changed orientation

      <StackLayout Orientation="Horizontal">
                <Label Grid.Row="0" Text="Charwaka" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="24" FontAttributes="Bold" BackgroundColor="LightGray"
                   TextColor="CadetBlue" HorizontalOptions="Start" />
                <Label Grid.Row="0" Text="Charwaka" HorizontalOptions="Center" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="24" FontAttributes="Bold" BackgroundColor="LightGray"
                   TextColor="CadetBlue" />
                <Label Grid.Row="0" Text="Charwaka" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="24" FontAttributes="Bold" BackgroundColor="LightGray"
                   TextColor="CadetBlue" HorizontalOptions="End" />
            </StackLayout>
    

    I hope you understand

Sign In or Register to comment.