View.VerticalOptions Property

Definition

Gets or sets the LayoutOptions that define how the element gets laid in a layout cycle. This is a bindable property.

public Xamarin.Forms.LayoutOptions VerticalOptions { get; set; }
member this.VerticalOptions : Xamarin.Forms.LayoutOptions with get, set

Property Value

A LayoutOptions which defines how to lay out the element. Default value is Fill unless otherwise documented.

Remarks

Assigning the VerticalOptions modifies how the element is laid out when there is excess space available along the Y axis from the parent layout. Additionally it specifies if the element should consume leftover space in the Y axis from the parent layout. If multiple children of a layout are set to expand, the extra space is distributed proportionally.

This example creates four views and adds them to a stack, each laying out in a different manner.

private View CreateButtons ()
{
  var button1 = new Button {Text = "TopAligned", VerticalOptions=LayoutOptions.Start};
  var button2 = new Button {Text = "CenterAligned", VerticalOptions=LayoutOptions.Center};
  var button3 = new Button {Text = "BottomAligned", VerticalOptions=LayoutOptions.End};
  var button4 = new Button {Text = "Fill", VerticalOptions=LayoutOptions.Fill};

  StackLayout stack = new StackLayout {
    Orientation = StackOrientation.Horizontal,
    Children = {
      button1,
      button2,
      button3,
      button4
    }
  };

  return stack;
}

Applies to