Xamarin Forms : How to make button appear at the bottom of a page
This worked for me.
<StackLayout BackgroundColor="#2D3033">
<Button Clicked ="Button_Clicked"
Text="Login"
BackgroundColor="#007F00"
BorderColor="#004C00"
BorderWidth="1"
TextColor="white"
HorizontalOptions="CenterAndExpand"
VerticalOptions="EndAndExpand"
/>
</StackLayout>
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackLayout Grid.Row="0">
</StackLayout>
<StackLayout Grid.Row="1" VerticalOptions="End">
<controls:STButton Text="Yeni Görev Ekle" />
</StackLayout>
</Grid>
</ContentPage.Content>
%100 works ;)
With a Grid
is simple just do this:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:shared_forms" x:Class="shared_forms.shared_formsPage">
<Grid>
<Label Text="Enter A Code" VerticalOptions="Center" HorizontalOptions="Center" />
<Button Text="Reveal Code" x:Name="RevealCode" HorizontalOptions="CenterAndExpand" VerticalOptions="End" />
</Grid>
</ContentPage>
With StackLayout
:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:shared_forms" x:Class="shared_forms.shared_formsPage">
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Horizontal" VerticalOptions="Start">
<!-- top controls -->
<Label Text="Enter A Code" VerticalOptions="Center" HorizontalOptions="CenterAndExpand" />
</StackLayout>
<StackLayout VerticalOptions="CenterAndExpand">
<!-- middle controls -->
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="End">
<!-- bottom controls -->
<Button Text="Reveal Code" x:Name="RevealCode" HorizontalOptions="CenterAndExpand" />
</StackLayout>
</StackLayout>
</ContentPage>
Result: