I'm trying to make the grid cells exactly 50% of the width, which works fine. However, I want the buttons to be 50% within the cell and not expand to the size of the cell.
Xaml below, how to I modify the Button to be 50% width of the cell it is in.
<Grid Padding="10,10,10,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="0" Text="Back" Command="" BackgroundColor="Red" TextColor="White" ></Button>
<Button Grid.Row="0" Grid.Column="1" Text="Done" Command="" BackgroundColor="Green" TextColor="White"></Button>
</Grid>
how to I modify the Button to be 50% width of the cell it is in.
You can put the Button into the StackLayout so that the width of the Button is half the width of the GridCell.
Solution code:
<Grid Padding="10,10,10,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*"></ColumnDefinition>
<ColumnDefinition Width="50*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackLayout Grid.Row="0" Grid.Column="0" HorizontalOptions="Center">
<Button Text="Back" Command="{Binding .}" BackgroundColor="Red" TextColor="White" ></Button>
</StackLayout>
<StackLayout Grid.Row="0" Grid.Column="1" HorizontalOptions="Center">
<Button Text="Done" Command="{Binding .}" BackgroundColor="Green" TextColor="White"></Button>
</StackLayout>
</Grid>