Multiple label alignment in xamarin forms xaml - xaml

I am working on xaml part in which i have took stack layout with list view . i am new to xamarin but dont know how to align label under their main category .i want to align label properly
my code for xaml is below.
<ContentPage.Content>
<StackLayout VerticalOptions="FillAndExpand" Margin="0,30,0,0" HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<Label Text="Branch" FontSize="11" TextColor="#0A7475" HorizontalOptions="Start" Margin="10,0,0,0" />
<Label Text="Restock Reason" TextColor="#0A7475" FontSize="11" HorizontalOptions="Start" Margin="20,0,0,0" />
<Label Text="Qty" TextColor="#0A7475" FontSize="11" HorizontalOptions="Start" Margin="20,0,0,0" />
<Label Text="Vendor" TextColor="#0A7475" FontSize="11" HorizontalOptions="Start" Margin="20,0,0,0" />
<Label Text="Created On" TextColor="#0A7475" FontSize="11" HorizontalOptions="Start" Margin="20,0,0,0" />
</StackLayout>
<ListView x:Name="listViewn" BackgroundColor="White">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" HorizontalOptions="StartAndExpand">
<Label x:Name="Branchh" TextColor="Gray" FontSize="11" HorizontalOptions="Start" Text="{Binding Branch}" Margin="10,5,0,10" />
<Label x:Name="reason" TextColor="#325772" FontSize="11" Text="{Binding Reason}" Margin="20,5,0,10" />
<Label x:Name="Qtty" TextColor="Gray" FontSize="11" HorizontalOptions="Center" Text="{Binding Qty}" Margin="0,5,0,0" />
<Label x:Name="vendor" TextColor="Gray" FontSize="11" Text="{Binding Vendor}" Margin="20,5,0,10" />
<Label x:Name="schedDate" TextColor="Gray" HorizontalOptions="End" FontSize="11" Text="{Binding SchedDate}" Margin="0,5,10,10" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>

As SushiHangover suggested, use a grid to allow you to align your columns.
Like this
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height"Auto"/>
<RowDefinition Height"*"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="Branch" FontSize="11" TextColor="#0A7475" HorizontalOptions="Start" Margin="10,0,0,0" />
<Label Grid.Column="1" Text="Restock Reason" TextColor="#0A7475" FontSize="11" HorizontalOptions="Start" Margin="20,0,0,0" />
<Label Grid.Column="2" Text="Qty" TextColor="#0A7475" FontSize="11" HorizontalOptions="Start" Margin="20,0,0,0" />
<Label Grid.Column="3" Text="Vendor" TextColor="#0A7475" FontSize="11" HorizontalOptions="Start" Margin="20,0,0,0" />
<Label Grid.Column="4" Text="Created On" TextColor="#0A7475" FontSize="11" HorizontalOptions="Start" Margin="20,0,0,0" />
</Grid>
<ListView Grid.Row="1" x:Name="listViewn" BackgroundColor="White">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" TextColor="Gray" FontSize="11" HorizontalOptions="Start" Text="{Binding Branch}" Margin="10,5,0,10" />
<Label Grid.Column="1" TextColor="#325772" FontSize="11" Text="{Binding Reason}" Margin="20,5,0,10" />
<Label Grid.Column="2" TextColor="Gray" FontSize="11" HorizontalOptions="Center" Text="{Binding Qty}" Margin="0,5,0,0" />
<Label Grid.Column="3" TextColor="Gray" FontSize="11" Text="{Binding Vendor}" Margin="20,5,0,10" />
<Label Grid.Column="4" TextColor="Gray" HorizontalOptions="End" FontSize="11" Text="{Binding SchedDate}" Margin="0,5,10,10" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</ContentPage.Content>
You can also put the header into a listview header but that will scroll up the page with the listview.

Related

Controls overlaps other controls and need more space

My listview when new items are added overlaps the buttons. The buttons seems to have same place on the center of application. I would love to have them at the bottom. From the other hand listview should expand to the buttons and then scroll should appear. Last thing is the listview itself overlaps top part of controls and there is need to make more space i suppose (i highlited it on black on the picture. How can i fix that? Below screnshoot how it looks at the moment and current code as well. Thanks.
Full 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"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="MobileAppXamarinForms.Views.Order.OrderModifyPage"
Title="{Binding SelectedOrder.OrderId, StringFormat='Numer zamówienia: {0}'}">
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<Grid ColumnSpacing="4" HorizontalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Text="{Binding SelectedOrder.OrderId, StringFormat='NUMER ZAMÓWIENIA: {0}'}" FontSize="16" TextColor="Gray" Grid.Column="0" Padding="30,1,1,1" FontAttributes="None" HorizontalOptions="FillAndExpand" VerticalOptions="Center"/>
<Label Text=" " Grid.Column="1" HorizontalOptions="FillAndExpand"/>
<Label Text="KLIENT:" FontSize="15" VerticalOptions="Center" Grid.Column="2" HorizontalOptions="Start"/>
<Label Text="{Binding SelectedClient.Value, StringFormat='{0}'}" FontSize="16" TextColor="Gray" Grid.Column="3"
Padding="5,1,1,1" FontAttributes="None" HorizontalOptions="FillAndExpand" VerticalOptions="Center"/>
<Label Text="NA DZIEŃ:" Grid.Column="4" HorizontalOptions="FillAndExpand" VerticalOptions="Center"/>
<DatePicker Date="{Binding SelectedTargetDate, Mode=TwoWay}" Format="dd.MM.yyyy"
Grid.Column="5" HorizontalOptions="FillAndExpand"/>
</Grid>
<Grid ColumnSpacing="4" HorizontalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Text="BUTLA:" FontSize="15" TextColor="Gray" Grid.Column="0" Padding="30,1,1,1" FontAttributes="None" HorizontalOptions="FillAndExpand" VerticalOptions="Center"/>
<Picker Title="BUTLA" ItemsSource="{Binding Bottles}" SelectedItem="{Binding SelectedBottle, Mode=TwoWay}" ItemDisplayBinding="{Binding Value}" SelectedIndex="{Binding Id}" FontSize="15" VerticalOptions="Center" Grid.Column="1" HorizontalOptions="FillAndExpand"/>
<Label Text=" " Grid.Column="2" HorizontalOptions="FillAndExpand"/>
<Label Text="ILOŚĆ:" FontSize="15" VerticalOptions="Center" Grid.Column="3" HorizontalOptions="Start"/>
<Entry Placeholder="Ilość" Text="{Binding SelectedAmount, Mode=TwoWay}" Keyboard="Numeric" MaxLength="5" Grid.Column="4" HorizontalOptions="Start"/>
</Grid>
<StackLayout Orientation="Vertical" VerticalOptions="Fill">
<Grid ColumnSpacing="0" RowSpacing="0" VerticalOptions="Fill">
<!--Listview section-->
<ListView ItemsSource="{Binding SelectedItems}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" VerticalScrollBarVisibility="Always">
<ListView.Header>
<Grid BackgroundColor="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="1*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Text="Nazwa butli" HorizontalOptions="Fill" Grid.Column="0" FontSize="Medium" FontAttributes="Bold" BackgroundColor="LightBlue" TextColor="White" HorizontalTextAlignment="Center" Margin="1"/>
<Label Text="Pełna?" HorizontalOptions="Fill" Grid.Column="1" FontSize="Medium" FontAttributes="Bold" BackgroundColor="LightBlue" TextColor="White" HorizontalTextAlignment="Center" Margin="1"/>
<Label Text="Ilość" HorizontalOptions="Fill" Grid.Column="2" FontSize="Medium" FontAttributes="Bold" BackgroundColor="LightBlue" TextColor="White" HorizontalTextAlignment="Center" Margin="1"/>
<Label Text="Kwota" HorizontalOptions="Fill" Grid.Column="3" FontSize="Medium" FontAttributes="Bold" BackgroundColor="LightBlue" TextColor="White" HorizontalTextAlignment="Center" Margin="1"/>
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid BackgroundColor="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Text ="{Binding BottleTypeName}" BackgroundColor="WhiteSmoke" HorizontalOptions="Fill" HorizontalTextAlignment="Center"></Label>
<Label Grid.Column="1" Text ="{Binding BottleIsFilled}" BackgroundColor="WhiteSmoke" HorizontalOptions="Fill" HorizontalTextAlignment="Center"></Label>
<Label Grid.Column="2" Text ="{Binding Amount}" BackgroundColor="WhiteSmoke" HorizontalOptions="Fill" HorizontalTextAlignment="Center"></Label>
<Label Grid.Column="3" Text ="{Binding Price}" BackgroundColor="WhiteSmoke" HorizontalOptions="Fill" HorizontalTextAlignment="Center"></Label>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!--Buttons section-->
<Grid ColumnSpacing="0" RowSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="33.33*"/>
<ColumnDefinition Width="33.33*"/>
<ColumnDefinition Width="33.33*"/>
<ColumnDefinition Width="33.33*"/>
</Grid.ColumnDefinitions>
<Button Text="Dodaj butlę"
VerticalOptions="Center"
Margin="20"
BackgroundColor="DarkMagenta"
TextColor="White"
FontSize="20"
FontAttributes="Bold"
Command="{Binding SaveBottleCommand}" Grid.Column="0" HorizontalOptions="FillAndExpand"/>
<Button Text="Usuń butlę"
VerticalOptions="Center"
Margin="20"
BackgroundColor="MediumVioletRed"
TextColor="White"
FontSize="20"
FontAttributes="Bold"
Command="{Binding RemoveBottleCommand}" Grid.Column="1" HorizontalOptions="FillAndExpand"/>
<Button Text="Ok"
VerticalOptions="Center"
Margin="20"
BackgroundColor="Red"
TextColor="White"
FontSize="20"
FontAttributes="Bold"
Command="{Binding ClearFormCommand}" Grid.Column="2" HorizontalOptions="FillAndExpand"/>
<Button Text="Ok"
VerticalOptions="Center"
Margin="20"
BackgroundColor="OrangeRed"
TextColor="White"
FontSize="20"
FontAttributes="Bold"
Command="{Binding ClearFormCommand}" Grid.Column="3" HorizontalOptions="FillAndExpand"/>
</Grid>
</Grid>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
EDIT 1:
Current 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"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="MobileAppXamarinForms.Views.Order.OrderModifyPage"
Title="{Binding SelectedOrder.OrderId, StringFormat='Numer zamówienia: {0}'}">
<ContentPage.Content>
<StackLayout>
<Grid HorizontalOptions="FillAndExpand" VerticalOptions="Center">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- ********** COL 0 | ROW 0 ********** -->
<Grid Column="0" Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Text="{Binding SelectedOrder.OrderId, StringFormat='NUMER ZAMÓWIENIA: {0}'}" FontSize="16" TextColor="Gray"
Grid.Column="0" Padding="30,1,1,1" FontAttributes="None" VerticalOptions="Center"/>
<Label Text="KLIENT:" FontSize="15" VerticalOptions="Center" Grid.Column="1"/>
<Label Text="{Binding SelectedClient.Value, StringFormat='{0}'}" FontSize="16" TextColor="Gray" Grid.Column="2" FontAttributes="None" VerticalOptions="Center"/>
<Label Text="NA DZIEŃ:" Grid.Column="3" VerticalOptions="Center"/>
<DatePicker Date="{Binding SelectedTargetDate, Mode=TwoWay}" Format="dd.MM.yyyy" Grid.Column="4"/>
</Grid>
<!-- ********** COL 0 | ROW 1 ********** -->
<Grid Column="0" Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Text="BUTLA:" FontSize="15" TextColor="Gray" Grid.Column="0" Padding="30,1,1,1"
FontAttributes="None" HorizontalOptions="FillAndExpand" VerticalOptions="Center"/>
<Picker Title="BUTLA" ItemsSource="{Binding Bottles}" SelectedItem="{Binding SelectedBottle, Mode=TwoWay}"
ItemDisplayBinding="{Binding Value}" SelectedIndex="{Binding Id}" FontSize="15"
VerticalOptions="Center" Grid.Column="1" HorizontalOptions="FillAndExpand"/>
<Label Text=" " Grid.Column="2" HorizontalOptions="FillAndExpand"/>
<Label Text="ILOŚĆ:" FontSize="15" VerticalOptions="Center" Grid.Column="3" HorizontalOptions="Start"/>
<Entry Placeholder="Ilość" Text="{Binding SelectedAmount, Mode=TwoWay}" Keyboard="Numeric" MaxLength="5" Grid.Column="4" HorizontalOptions="Start"/>
</Grid>
<!-- ********** COL 0 | ROW 2 ********** -->
<Grid VerticalOptions="FillAndExpand" Column="0" Row="2">
<Grid.RowDefinitions>
<RowDefinition Grid.ColumnSpan="1" />
<RowDefinition Grid.ColumnSpan="1" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--Listview section-->
<ListView ItemsSource="{Binding SelectedItems}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" VerticalScrollBarVisibility="Always" Grid.Column="0" Grid.Row="0">
<ListView.Header>
<Grid BackgroundColor="White" Grid.Column="0" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="1*"></ColumnDefinition>
<ColumnDefinition Width="1*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Text="Nazwa butli" HorizontalOptions="Fill" Grid.Column="0" FontSize="Medium" FontAttributes="Bold" BackgroundColor="LightBlue" TextColor="White" HorizontalTextAlignment="Center" Margin="1"/>
<Label Text="Pełna?" HorizontalOptions="Fill" Grid.Column="1" FontSize="Medium" FontAttributes="Bold" BackgroundColor="LightBlue" TextColor="White" HorizontalTextAlignment="Center" Margin="1"/>
<Label Text="Ilość" HorizontalOptions="Fill" Grid.Column="2" FontSize="Medium" FontAttributes="Bold" BackgroundColor="LightBlue" TextColor="White" HorizontalTextAlignment="Center" Margin="1"/>
<Label Text="Kwota" HorizontalOptions="Fill" Grid.Column="3" FontSize="Medium" FontAttributes="Bold" BackgroundColor="LightBlue" TextColor="White" HorizontalTextAlignment="Center" Margin="1"/>
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid BackgroundColor="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Text ="{Binding BottleTypeName}" BackgroundColor="WhiteSmoke" HorizontalOptions="Fill" HorizontalTextAlignment="Center"></Label>
<Label Grid.Column="1" Text ="{Binding BottleIsFilled}" BackgroundColor="WhiteSmoke" HorizontalOptions="Fill" HorizontalTextAlignment="Center"></Label>
<Label Grid.Column="2" Text ="{Binding Amount}" BackgroundColor="WhiteSmoke" HorizontalOptions="Fill" HorizontalTextAlignment="Center"></Label>
<Label Grid.Column="3" Text ="{Binding Price}" BackgroundColor="WhiteSmoke" HorizontalOptions="Fill" HorizontalTextAlignment="Center"></Label>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
<!-- ********** COL 0 | ROW 3 ********** -->
<Grid BackgroundColor="White" Grid.Column="0" Grid.Row="3">
<Button Text="Dodaj butlę" Grid.Row="1"
VerticalOptions="Center"
Margin="20"
BackgroundColor="DarkMagenta"
TextColor="White"
FontSize="20"
FontAttributes="Bold"
Command="{Binding SaveBottleCommand}" Grid.Column="0" HorizontalOptions="FillAndExpand"/>
<Button Text="Usuń butlę" Grid.Row="1"
VerticalOptions="Center"
Margin="20"
BackgroundColor="MediumVioletRed"
TextColor="White"
FontSize="20"
FontAttributes="Bold"
Command="{Binding RemoveBottleCommand}" Grid.Column="1" HorizontalOptions="FillAndExpand"/>
<Button Text="Ok" Grid.Row="1"
VerticalOptions="Center"
Margin="20"
BackgroundColor="Red"
TextColor="White"
FontSize="20"
FontAttributes="Bold"
Command="{Binding ClearFormCommand}" Grid.Column="2" HorizontalOptions="FillAndExpand"/>
<Button Text="Ok" Grid.Row="1"
VerticalOptions="Center"
Margin="20"
BackgroundColor="OrangeRed"
TextColor="White"
FontSize="20"
FontAttributes="Bold"
Command="{Binding ClearFormCommand}" Grid.Column="3" HorizontalOptions="FillAndExpand"/>
</Grid>
</Grid>
</StackLayout>
</ContentPage.Content>
</ContentPage>
EDIT 3:
your ListView and buttons are both contained in a Grid with no RowDefintions, so both will occupy the same row and overlap. You need to place each one in its own row
I would love to have them at the bottom.
If you want to place button at the bottom , just set VerticalOptions="End" for Grid.
listview itself overlaps top part of controls and there is need to make more space.
You can use Margin to add space between control and ListView.
I modify your code, you can take a look:
<StackLayout Orientation="Vertical">
<Grid HorizontalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label
Grid.Column="0"
Padding="30,1,1,1"
FontAttributes="None"
FontSize="16"
HorizontalOptions="FillAndExpand"
Text="{Binding SelectedOrder.OrderId, StringFormat='NUMER ZAMÓWIENIA: {0}'}"
TextColor="Gray"
VerticalOptions="Center" />
<Label
Grid.Column="1"
HorizontalOptions="FillAndExpand"
Text=" " />
<Label
Grid.Column="2"
FontSize="15"
HorizontalOptions="Start"
Text="KLIENT:"
VerticalOptions="Center" />
<Label
Grid.Column="3"
Padding="5,1,1,1"
FontAttributes="None"
FontSize="16"
HorizontalOptions="FillAndExpand"
Text="{Binding SelectedClient.Value, StringFormat='{0}'}"
TextColor="Gray"
VerticalOptions="Center" />
<Label
Grid.Column="4"
HorizontalOptions="FillAndExpand"
Text="NA DZIEŃ:"
VerticalOptions="Center" />
<DatePicker
Grid.Column="5"
Date="{Binding SelectedTargetDate, Mode=TwoWay}"
Format="dd.MM.yyyy"
HorizontalOptions="FillAndExpand" />
</Grid>
<Grid Margin="5" HorizontalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label
Grid.Column="0"
Padding="30,1,1,1"
FontAttributes="None"
FontSize="15"
HorizontalOptions="FillAndExpand"
Text="BUTLA:"
TextColor="Gray"
VerticalOptions="Center" />
<Picker
Title="BUTLA"
Grid.Column="1"
FontSize="15"
HorizontalOptions="FillAndExpand"
ItemDisplayBinding="{Binding Value}"
ItemsSource="{Binding Bottles}"
SelectedIndex="{Binding Id}"
SelectedItem="{Binding SelectedBottle, Mode=TwoWay}"
VerticalOptions="Center" />
<Label
Grid.Column="2"
HorizontalOptions="FillAndExpand"
Text=" " />
<Label
Grid.Column="3"
FontSize="15"
HorizontalOptions="Start"
Text="ILOŚĆ:"
VerticalOptions="Center" />
<Entry
Grid.Column="4"
HorizontalOptions="Start"
Keyboard="Numeric"
MaxLength="5"
Placeholder="Ilość"
Text="{Binding SelectedAmount, Mode=TwoWay}" />
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Listview section -->
<ListView
ItemsSource="{Binding SelectedItems}"
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
VerticalScrollBarVisibility="Always">
<ListView.Header>
<Grid BackgroundColor="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Label
Grid.Column="0"
Margin="1"
BackgroundColor="LightBlue"
FontAttributes="Bold"
FontSize="Medium"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="Nazwa butli"
TextColor="White" />
<Label
Grid.Column="1"
Margin="1"
BackgroundColor="LightBlue"
FontAttributes="Bold"
FontSize="Medium"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="Pełna?"
TextColor="White" />
<Label
Grid.Column="2"
Margin="1"
BackgroundColor="LightBlue"
FontAttributes="Bold"
FontSize="Medium"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="Ilość"
TextColor="White" />
<Label
Grid.Column="3"
Margin="1"
BackgroundColor="LightBlue"
FontAttributes="Bold"
FontSize="Medium"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="Kwota"
TextColor="White" />
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid BackgroundColor="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label
Grid.Column="0"
BackgroundColor="WhiteSmoke"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="{Binding BottleTypeName}" />
<Label
Grid.Column="1"
BackgroundColor="WhiteSmoke"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="{Binding BottleIsFilled}" />
<Label
Grid.Column="2"
BackgroundColor="WhiteSmoke"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="{Binding Amount}" />
<Label
Grid.Column="3"
BackgroundColor="WhiteSmoke"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="{Binding Price}" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!-- Buttons section -->
<Grid Grid.Row="1" VerticalOptions="End">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="33.33*" />
<ColumnDefinition Width="33.33*" />
<ColumnDefinition Width="33.33*" />
<ColumnDefinition Width="33.33*" />
</Grid.ColumnDefinitions>
<Button
Grid.Column="0"
BackgroundColor="DarkMagenta"
Command="{Binding SaveBottleCommand}"
FontAttributes="Bold"
FontSize="20"
HorizontalOptions="FillAndExpand"
Text="Dodaj butlę"
TextColor="White"
VerticalOptions="Fill" />
<Button
Grid.Column="1"
BackgroundColor="MediumVioletRed"
Command="{Binding RemoveBottleCommand}"
FontAttributes="Bold"
FontSize="20"
HorizontalOptions="FillAndExpand"
Text="Usuń butlę"
TextColor="White"
VerticalOptions="Center" />
<Button
Grid.Column="2"
BackgroundColor="Red"
Command="{Binding ClearFormCommand}"
FontAttributes="Bold"
FontSize="20"
HorizontalOptions="FillAndExpand"
Text="Ok"
TextColor="White"
VerticalOptions="Center" />
<Button
Grid.Column="3"
BackgroundColor="OrangeRed"
Command="{Binding ClearFormCommand}"
FontAttributes="Bold"
FontSize="20"
HorizontalOptions="FillAndExpand"
Text="Ok"
TextColor="White"
VerticalOptions="Center" />
</Grid>
</Grid>
</StackLayout>
Update:
Those items are cutted how to make more space for those item's texts?
Setting Picker ColumnDefinitions width=80 or higher.
How to make this more to the left?
Try to set Label HorizontalOptions="StartAndExpand"
When i select item in listview i only see colored orange line - how to make full item select?
Delete ListView ViewCell grid and Lable BackgroundColor="WhiteSmoke"
<StackLayout Orientation="Vertical">
<Grid HorizontalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label
Grid.Column="0"
Padding="30,1,1,1"
FontAttributes="None"
FontSize="16"
HorizontalOptions="FillAndExpand"
Text="{Binding SelectedOrder.OrderId, StringFormat='NUMER ZAMÓWIENIA: {0}'}"
TextColor="Gray"
VerticalOptions="Center" />
<Label
Grid.Column="1"
HorizontalOptions="FillAndExpand"
Text=" " />
<Label
Grid.Column="2"
FontSize="15"
HorizontalOptions="Start"
Text="KLIENT:"
VerticalOptions="Center" />
<Label
Grid.Column="3"
Padding="5,1,1,1"
FontAttributes="None"
FontSize="16"
HorizontalOptions="FillAndExpand"
Text="{Binding SelectedClient.Value, StringFormat='{0}'}"
TextColor="Gray"
VerticalOptions="Center" />
<Label
Grid.Column="4"
HorizontalOptions="StartAndExpand"
Text="NA DZIEŃ:"
VerticalOptions="Center" />
<DatePicker
Grid.Column="5"
Date="{Binding SelectedTargetDate, Mode=TwoWay}"
Format="dd.MM.yyyy"
HorizontalOptions="StartAndExpand" />
</Grid>
<Grid Margin="5" HorizontalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label
Grid.Column="0"
Padding="30,1,1,1"
FontAttributes="None"
FontSize="15"
HorizontalOptions="FillAndExpand"
Text="BUTLA:"
TextColor="Gray"
VerticalOptions="Center" />
<Picker
Title="BUTLA"
Grid.Column="1"
FontSize="15"
HorizontalOptions="FillAndExpand"
ItemDisplayBinding="{Binding Value}"
ItemsSource="{Binding Bottles}"
SelectedIndex="{Binding Id}"
SelectedItem="{Binding SelectedBottle, Mode=TwoWay}"
VerticalOptions="Center" />
<Label
Grid.Column="2"
HorizontalOptions="FillAndExpand"
Text=" " />
<Label
Grid.Column="3"
FontSize="15"
HorizontalOptions="Start"
Text="ILOŚĆ:"
VerticalOptions="Center" />
<Entry
Grid.Column="4"
HorizontalOptions="Start"
Keyboard="Numeric"
MaxLength="5"
Placeholder="Ilość"
Text="{Binding SelectedAmount, Mode=TwoWay}" />
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Listview section -->
<ListView
ItemsSource="{Binding bottles}"
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
VerticalScrollBarVisibility="Always">
<ListView.Header>
<Grid BackgroundColor="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Label
Grid.Column="0"
Margin="1"
BackgroundColor="LightBlue"
FontAttributes="Bold"
FontSize="Medium"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="Nazwa butli"
TextColor="White" />
<Label
Grid.Column="1"
Margin="1"
BackgroundColor="LightBlue"
FontAttributes="Bold"
FontSize="Medium"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="Pełna?"
TextColor="White" />
<Label
Grid.Column="2"
Margin="1"
BackgroundColor="LightBlue"
FontAttributes="Bold"
FontSize="Medium"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="Ilość"
TextColor="White" />
<Label
Grid.Column="3"
Margin="1"
BackgroundColor="LightBlue"
FontAttributes="Bold"
FontSize="Medium"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="Kwota"
TextColor="White" />
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label
Grid.Column="0"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="{Binding BottleTypeName}" />
<Label
Grid.Column="1"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="{Binding BottleIsFilled}" />
<Label
Grid.Column="2"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="{Binding Amount}" />
<Label
Grid.Column="3"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"
Text="{Binding Price}" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!-- Buttons section -->
<Grid Grid.Row="1" VerticalOptions="End">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="33.33*" />
<ColumnDefinition Width="33.33*" />
<ColumnDefinition Width="33.33*" />
<ColumnDefinition Width="33.33*" />
</Grid.ColumnDefinitions>
<Button
Grid.Column="0"
BackgroundColor="DarkMagenta"
Command="{Binding SaveBottleCommand}"
FontAttributes="Bold"
FontSize="20"
HorizontalOptions="FillAndExpand"
Text="Dodaj butlę"
TextColor="White"
VerticalOptions="Fill" />
<Button
Grid.Column="1"
BackgroundColor="MediumVioletRed"
Command="{Binding RemoveBottleCommand}"
FontAttributes="Bold"
FontSize="20"
HorizontalOptions="FillAndExpand"
Text="Usuń butlę"
TextColor="White"
VerticalOptions="Center" />
<Button
Grid.Column="2"
BackgroundColor="Red"
Command="{Binding ClearFormCommand}"
FontAttributes="Bold"
FontSize="20"
HorizontalOptions="FillAndExpand"
Text="Ok"
TextColor="White"
VerticalOptions="Center" />
<Button
Grid.Column="3"
BackgroundColor="OrangeRed"
Command="{Binding ClearFormCommand}"
FontAttributes="Bold"
FontSize="20"
HorizontalOptions="FillAndExpand"
Text="Ok"
TextColor="White"
VerticalOptions="Center" />
</Grid>
</Grid>
</StackLayout>

Free space using FillAndExpand

Im' working on XAML view and I want to create simple view with left side bar and the content with Grid and inside grid I have some buttons, that I want to achieve is to fill all form
Code:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:App.ViewModels"
mc:Ignorable="d"
x:Class="App.Views.UserSelectionPage">
<ContentPage.Content>
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Vertical" BackgroundColor="#093145" HorizontalOptions="Start" VerticalOptions="FillAndExpand" >
<Label Text="AppName"
Grid.Row="0"
Grid.Column="1"
HorizontalOptions="Center"
VerticalOptions="Center"
FontSize="Header"
TextColor="White"
Margin="15,0,10,15" />
</StackLayout>
<StackLayout Orientation="Vertical" VerticalOptions="End" BackgroundColor="#093145">
<Image Source="Assets/LargeTitle.scale-100.png"
Grid.Row="0"
Grid.Column="0"
HorizontalOptions="Center"
WidthRequest="90"
HeightRequest="90"
Margin="15,0,10,15"
VerticalOptions="Center"/>
</StackLayout>
</StackLayout>
<Grid BackgroundColor="AliceBlue">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!--<BoxView Color="#505CA9" Grid.Row="0" Grid.ColumnSpan="3" />-->
<Button Text="Use username instead"
Command="{Binding ToggleNewUserCommand}"
Grid.Row="0"
Grid.Column="2"
VerticalOptions="Center"
HorizontalOptions="End"
BackgroundColor="Transparent"
FontSize="Title"
TextColor="White"
Margin="15,0,10,15"/>
<Button x:Name="userOne"
d:Text="GQ"
Text="{Binding UserSelectionList[0].Abbreviation}"
Command="{Binding ButtonSelectedCommand}"
CommandParameter="{x:Reference userOne}"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
BorderWidth="1"
FontSize="92"
CornerRadius="160"
HeightRequest="320"
WidthRequest="320"
Margin="0,40,0,40"
Grid.Row="1"
Grid.Column="0"
BackgroundColor="{Binding UserSelectionList[0].BackgroundColor}"
d:BackgroundColor="#093145"/>
<Button x:Name="userTwo"
d:Text="LR"
Text="{Binding UserSelectionList[1].Abbreviation}"
Command="{Binding ButtonSelectedCommand}"
CommandParameter="{x:Reference userTwo}"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
BorderWidth="1"
FontSize="92"
CornerRadius="160"
HeightRequest="320"
WidthRequest="320"
Margin="0,40,0,40"
Grid.Row="1"
Grid.Column="1"
BackgroundColor="{Binding UserSelectionList[1].BackgroundColor}"
d:BackgroundColor="#107896" />
<Button x:Name="userThree"
d:Text="AR"
Text="{Binding UserSelectionList[2].Abbreviation}"
Command="{Binding ButtonSelectedCommand}"
CommandParameter="{x:Reference userThree}"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
BorderWidth="1"
FontSize="92"
CornerRadius="160"
HeightRequest="320"
WidthRequest="320"
Margin="0,40,0,40"
Grid.Row="1"
Grid.Column="2"
BackgroundColor="{Binding UserSelectionList[2].BackgroundColor}"
d:BackgroundColor="#829356" />
<Button x:Name="userFour"
d:Text="RR"
Text="{Binding UserSelectionList[3].Abbreviation}"
Command="{Binding ButtonSelectedCommand}"
CommandParameter="{x:Reference userFour}"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
BorderWidth="1"
FontSize="92"
CornerRadius="160"
HeightRequest="320"
WidthRequest="320"
Grid.Row="2"
Grid.Column="0"
BackgroundColor="{Binding UserSelectionList[3].BackgroundColor}"
d:BackgroundColor="#EBC944" />
<Button x:Name="userFive"
d:Text="GQ"
Text="{Binding UserSelectionList[4].Abbreviation}"
Command="{Binding ButtonSelectedCommand}"
CommandParameter="{x:Reference userFive}"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
BorderWidth="1"
FontSize="92"
CornerRadius="160"
HeightRequest="320"
WidthRequest="320"
Grid.Row="2"
Grid.Column="1"
BackgroundColor="{Binding UserSelectionList[4].BackgroundColor}"
d:BackgroundColor="#F26D21" />
<Button x:Name="userSix"
d:Text="GQ"
Text="{Binding UserSelectionList[5].Abbreviation}"
CommandParameter="{x:Reference userSix}"
Command="{Binding ButtonSelectedCommand}"
TextColor="White"
HorizontalOptions="Center"
VerticalOptions="Center"
BorderWidth="1"
FontSize="92"
CornerRadius="160"
HeightRequest="320"
WidthRequest="320"
Grid.Row="2"
Grid.Column="2"
BackgroundColor="{Binding UserSelectionList[5].BackgroundColor}"
d:BackgroundColor="#C02F1D" />
</Grid>
</StackLayout>
</ContentPage.Content>
Problem is for some reason it has free space inclusive if I use FillAndExpand on main StackLayout
I read about that but people just say that I missing FillAndExpand, I think problem is because I use Orientation="Horizontal" into first StackLayout, but that is the way I found to merge side bar with gridview. How can I achieve this? Regards
Add HorizontalOptions to the Grid itself:
<Grid HorizontalOptions="FillAndExpand" BackgroundColor="AliceBlue">

set border to listview Xamarin form

I made a table with xamarin forms, but I would like the headers not to have blank spaces and also put borders, use table-striped, have the basic characteristics of a bootstrap table for example. Could you help me?. Thank you for you help.
Here my code.
<StackLayout BindingContext="{Binding OpportunityListViewModel}" Padding="8">
<ListView x:Name="ProposalListProduct"
ItemsSource="{Binding ProposalView}"
IsRefreshing="{Binding IsRefreshing}"
CachingStrategy="RecycleElement"
HasUnevenRows="True"
Margin="0">
<ListView.Header>
<Grid Margin="0" Padding="0" RowSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="20*" />
<ColumnDefinition Width="20*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Margin="0" Text="Item" FontSize="8" TextColor="Black" BackgroundColor="LightGray" HorizontalTextAlignment="Center" HorizontalOptions="Fill" />
<Label Grid.Row="0" Grid.Column="1" Margin="0" Text="Cant." FontSize="8" TextColor="Black" BackgroundColor="LightGray" HorizontalTextAlignment="Center" HorizontalOptions="Fill" />
<Label Grid.Row="0" Grid.Column="2" Margin="0" Text="Precio" FontSize="8" TextColor="Black" BackgroundColor="LightGray" HorizontalTextAlignment="Center" HorizontalOptions="Fill" />
<Label Grid.Row="0" Grid.Column="3" Margin="0" Text="Total" FontSize="8" TextColor="Black" BackgroundColor="LightGray" HorizontalTextAlignment="Center" HorizontalOptions="Fill" />
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Grid Margin="0" Padding="0" RowSpacing="0" ColumnSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="10*" />
<ColumnDefinition Width="20*" />
<ColumnDefinition Width="20*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<Label Grid.Column="0" Margin="0" x:Name="Nombre" Text="{Binding Nombre}" FontSize="8" TextColor="Black" VerticalTextAlignment="End" HorizontalTextAlignment="Start" />
<Label Grid.Column="1" Margin="0" x:Name="Cantidad" Text="{Binding Cantidad}" FontSize="8" TextColor="Black" VerticalTextAlignment="End" HorizontalTextAlignment="End"/>
<Label Grid.Column="2" Margin="0" x:Name="Precio" Text="{Binding Precio,StringFormat='{0:C2}'}" FontSize="8" TextColor="Black" VerticalTextAlignment="End" HorizontalTextAlignment="End"/>
<Label Grid.Column="3" Margin="0" x:Name="Total" Text="{Binding Total,StringFormat='{0:C2}'}" FontSize="8" TextColor="Black" VerticalTextAlignment="End" HorizontalTextAlignment="End"/>
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
you can do it like this:
<ListView ItemsSource="{Binding People}"
HasUnevenRows="True"
SeparatorVisibility="None">
<ListView.Header>
<Frame>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Text="Name"
HorizontalOptions="Center"
FontSize="Large"/>
<Label Grid.Column="1"
Text="Description"
HorizontalOptions="Center"
FontSize="Large"/>
<BoxView Grid.Row="1"
Grid.ColumnSpan="2"
HeightRequest="1"
BackgroundColor="LightGray"/>
</Grid>
</Frame>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Margin="20,10">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Text="{Binding Name}"
HorizontalOptions="Center"
VerticalOptions="Center"/>
<Label Grid.Column="1"
Text="{Binding Description}"
HorizontalOptions="Center"
VerticalOptions="Center"/>
<BoxView Grid.Row="1"
Grid.ColumnSpan="2"
HeightRequest="1"
BackgroundColor="LightGray"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

Xamarin aligning items in List View

I am using the following xaml in xamrin forms to create an order details page with the list of orders in a sub list-view however I am having a biit of difficulty in aligning the list view items.
<ContentPage.Content>
<ScrollView>
<StackLayout Spacing="2">
<Label Text="Order Number:"></Label>
<Label Text="{Binding Item.SopOrderNumber}"
LineBreakMode="NoWrap"
FontSize="20" />
<Label Text="Phone Number:" FontSize="20" ></Label>
<Label Text="{Binding Item.TelephoneNumber}"/>
<Button Command="{Binding SubmitCommand}" Text="Click To Call" TextColor="White"
FontAttributes="Bold" FontSize="Large" HorizontalOptions="FillAndExpand"
BackgroundColor="#088da5" />
<Label Text="{Binding Item.CustomerName}"
LineBreakMode="NoWrap"
FontSize="20" />
<Label Text="Order Status"
HorizontalOptions="StartAndExpand" />
<Picker x:Name="picker" Title="Order Status">
<Picker.ItemsSource >
<x:Array Type="{x:Type x:String}">
<x:String>Delivered</x:String>
<x:String>Damaged</x:String>
<x:String>Missing</x:String>
</x:Array>
</Picker.ItemsSource>
</Picker>
<Label Text="Order Details" FontSize="Large"></Label>
<ListView x:Name="DeliveryItemsList" HeightRequest="80" HasUnevenRows="True" >
<ListView.ItemTemplate >
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal">
<StackLayout Orientation="Horizontal" Padding="10" Spacing="15">
<Label Text="{Binding ItemNumber}" FontSize="20" ></Label>
<Label Text="{Binding StockCode}" FontSize="20" TextColor="Gray"></Label>
<Label Text="{Binding StockDescription}" FontSize="20" TextColor="Gray"></Label>
<Label Text="{Binding Price}" TextColor="Gray" FontSize="20" ></Label>
<Label Text="{Binding Qty}" TextColor="Gray" FontSize="20" ></Label>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Label Text="Notes"
HorizontalOptions="StartAndExpand"
/>
<Editor x:Name="txtNotes"
VerticalOptions="FillAndExpand" HeightRequest="20"></Editor>
<Sig:SignaturePadView x:Name="signaturePad" />
<Image x:Name="PhotoSource" ></Image>
<Button Command="{Binding SubmitCommand}" Text="Take Picture of Delivery" x:Name="btnTakePhto" Clicked="BtnTakePhto_Clicked" TextColor="White"
FontAttributes="Bold" FontSize="Large" HorizontalOptions="FillAndExpand"
BackgroundColor="#088da5" />
<Button Text="Update Order" BackgroundColor="AliceBlue" Clicked="Update_Order_Clicked"></Button>
<Button Text="Update Order and Goto Next Job" BackgroundColor="AliceBlue" Clicked="Update_Order_Clicked"></Button>
</StackLayout>
</ScrollView>
</ContentPage.Content>
As you can see from the image the items in the Listview are not in line with each other how can i make them so aligned.
Edit 2
Hi Again I AM afraid I tried the below answer but it didn't work in end it looked sound.
<ListView x:Name="DeliveryItemsList" HeightRequest="80" HasUnevenRows="True" >
<ListView.ItemTemplate >
<DataTemplate>
<ViewCell>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
</Grid>
<Label Text="{Binding ItemNumber}" FontSize="20" ></Label>
<Label Text="{Binding StockCode}" FontSize="20" TextColor="Gray"></Label>
<Label Text="{Binding StockDescription}" FontSize="20" TextColor="Gray"></Label>
<Label Text="{Binding Price}" TextColor="Gray" FontSize="20" ></Label>
<Label Text="{Binding Qty}" TextColor="Gray" FontSize="20" ></Label>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
If you want things to align, StackLayout is probably not the way to do it. StackLayout allocates space to each child element based on how much it needs, so if each row in your list has differing width requirements for different elements, like price, you'll get the kind of layout you see.
A better approach would be Grid, which gives you explicit control over how wide each column is:
<ListView.ItemTemplate >
<DataTemplate>
<ViewCell>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
</Grid>
<Label Text="{Binding ItemNumber}" Grid.Column="0" FontSize="20" ></Label>
<Label Text="{Binding StockCode}" Grid.Column="1" FontSize="20" TextColor="Gray"></Label>
<Label Text="{Binding StockDescription}" Grid.Column="2" FontSize="20" TextColor="Gray"></Label>
<Label Text="{Binding Price}" Grid.Column="3" TextColor="Gray" FontSize="20" ></Label>
<Label Text="{Binding Qty}" Grid.Column="4" TextColor="Gray" FontSize="20" ></Label>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
In this example, each column is defined to have an equal width (dividing the available width evenly), but you can adjust as you see fit.
You could change one of the ColumnDefinitions to Width="1.5*" which would allocate 1.5 times the space to that column as it does to the other columns. Or could you define a column with Width="100" which would give it a fixed size regardless of the width of the screen.
There is also Width="Auto" which lets you set the width of the column based on the amount of space needed by the contents of that column, but since each row in your ListView is a different Grid, you'd end up with the same problem as you are having now with StackLayout.

Xamarin - Not occupying the whole area in the screen using grid

I have 4 buttons in the bottom part of the screen as menus and I had used grid to show 4 buttons with same width and height and will occupy the whole screen. I have these codes but the result is not they way i wanted. It is not occupying the whole screen. Please help me how can I achieve it. Thanks.
<AbsoluteLayout BackgroundColor="#BC3022" MinimumHeightRequest="20" Padding="0,10,10,10" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid ColumnSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<BoxView Grid.Row="0" Grid.Column="0"/>
<StackLayout Grid.Row="0" Grid.Column="0" Padding="10,2,10,2">
<Image Source="home.png" WidthRequest="40" HeightRequest="25"/>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Home</Label>
</StackLayout>
<BoxView Grid.Row="0" Grid.Column="1"/>
<StackLayout Grid.Row="0" Grid.Column="1" Padding="10,2,10,2">
<Image Source="jobs.png" WidthRequest="40" HeightRequest="25">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnJobsGestureTap" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Jobs</Label>
</StackLayout>
<BoxView Grid.Row="0" Grid.Column="2"/>
<StackLayout Grid.Row="0" Grid.Column="2" Padding="10,2,10,2">
<Image Source="sync.png" WidthRequest="40" HeightRequest="25"/>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Sync</Label>
</StackLayout>
<BoxView Grid.Row="0" Grid.Column="3"/>
<StackLayout Grid.Row="0" Grid.Column="3" Padding="10,2,10,2">
<Image Source="logout.png" WidthRequest="40" HeightRequest="25">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnLogoutGestureTap" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Signout</Label>
</StackLayout>
</Grid>
</AbsoluteLayout>
This is how it looks:
Try to replace your code with below code:
<StackLayout BackgroundColor="#BC3022" MinimumHeightRequest="20" Padding="10,10,10,10" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid ColumnSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25*" />
<ColumnDefinition Width="25*" />
<ColumnDefinition Width="25*" />
<ColumnDefinition Width="25*" />
</Grid.ColumnDefinitions>
<BoxView Grid.Row="0" Grid.Column="0"/>
<StackLayout Grid.Row="0" Grid.Column="0" Padding="10,2,10,2">
<Image Source="home.png" WidthRequest="40" HeightRequest="25"/>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Home</Label>
</StackLayout>
<BoxView Grid.Row="0" Grid.Column="1"/>
<StackLayout Grid.Row="0" Grid.Column="1" Padding="10,2,10,2">
<Image Source="jobs.png" WidthRequest="40" HeightRequest="25">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnJobsGestureTap" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Jobs</Label>
</StackLayout>
<BoxView Grid.Row="0" Grid.Column="2"/>
<StackLayout Grid.Row="0" Grid.Column="2" Padding="10,2,10,2">
<Image Source="sync.png" WidthRequest="40" HeightRequest="25"/>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Sync</Label>
</StackLayout>
<BoxView Grid.Row="0" Grid.Column="3"/>
<StackLayout Grid.Row="0" Grid.Column="3" Padding="10,2,10,2">
<Image Source="logout.png" WidthRequest="40" HeightRequest="25">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnLogoutGestureTap" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Label Text="" TextColor="White" FontSize="15" HorizontalOptions="Center">Signout</Label>
</StackLayout>
</Grid>
</StackLayout>