Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Xamarin forms: How to set the VerticalOptions value of StackLayout from viewmodel?

$
0
0

I tried like below:

Created a new property named verticalOption:

private LayoutOptions verticalOption;

public LayoutOptions VerticalOption
{
    get => verticalOption;
    set
    {
        verticalOption = value;
        OnPropertyChanged(nameof(VerticalOption));
    }
}

Then set its value initially as FillAndExpand:

VerticalOption = LayoutOptions.FillAndExpand;

At one point I need its value as CenterAndExpand.

VerticalOption = LayoutOptions.CenterAndExpand;

Finally on XAML:

<StackLayout 
    Orientation="Vertical"
    HorizontalOptions="CenterAndExpand"
    VerticalOptions="{Binding VerticalOptio}">

But the CenterAndExpand value is not working. Always stack layout is on the top section, not coming to the center position. Is anything wrong with my implementation?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>