Bug 56951 - View.VerticalOptions property doesn't work when inside StackLayout
Summary: View.VerticalOptions property doesn't work when inside StackLayout
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-05-30 02:12 UTC by Brian B
Modified: 2017-05-30 14:52 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Brian B 2017-05-30 02:12:20 UTC
The VerticalOptions property for Views seems to not be applied when running code, if the views are nested inside <StackLayout>. I have tried setting the property from both the XAML page and from the code-behind.

When taking a view out of StackLayout, It renders correctly.
I've tested on both Android and iOS. I am unable to set the property from the code behind as well.

Here's the xaml code

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage 
        xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        x:Class="HelloWorld.GreetPage">
    <StackLayout>
        <Label x:Name="label" HorizontalOptions="Center" VerticalOptions="Center" Text="Hello World."></Label>
        <Slider x:Name="slider" ValueChanged="Slider_ValueChanged" HorizontalOptions="Center" VerticalOptions="Center" WidthRequest="250"></Slider>
    </StackLayout>
</ContentPage>

And here's the code I tried in the code behind:

public GreetPage()
{
    InitializeComponent();
    label.VerticalOptions = LayoutOptions.Center;
    slider.VerticalOptions = LayoutOptions.Center;
    slider.Value = 0.5;
}

Here's what it looks like on iOS - http://imgur.com/Bob8gmh

And here's what it looks like on Android - http://imgur.com/GFhx6qv

I am currently using Xamarin.Forms version 2.3.4.247
Windows 10, VS Community 2017
Comment 1 Brian B 2017-05-30 02:20:57 UTC
Here is a google drive link for the project zip.

https://drive.google.com/open?id=0B7-sA9ppGJoucU5VQm40Skc5NEE
Comment 2 Brian B 2017-05-30 12:47:47 UTC
Here is github link

https://github.com/Brian1217/VerticalOptionsBug
Comment 3 Brian B 2017-05-30 14:52:06 UTC
I am an idiot. please close. sorry.