1
votes

I show 4 button, at Row=0/Column=0, Row=0/Column=1, Row=1/Column=0, and Row=1/Column=1, I want to see 3 buttons equally taking. Im doing in Xamarin Forms Platform

<Grid x:Name="grid">
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Button Grid.Row="0" Text="Change Layout1" ></Button>
    <Button Grid.Row="1" Text="Change Layout2" ></Button>
    <Button Grid.Row="0" Grid.Column="1" Text="Change Layout3" ></Button>
    <Button Grid.Row="1" Grid.Column="1" Text="Change Layout4" ></Button>
</Grid>

On Dynamic Change i want to rearrange the grid when one button is removed,

private void Button_Clicked(object sender, EventArgs e)
{
   grid.Children.RemoveAt(1);
}

Can anyone suggest your ideas

1
Add screen view to better understand your question - Ziyad Godil

1 Answers

0
votes

When a button is clicked, I remove one of the grid items, and then need to rearrange the remaining items automatically. To achieve this, I’m using SetRowSpan() and SetRow().

private void Button_Clicked(object sender, EventArgs e)  
{
    grid.Children.RemoveAt(1);
    Grid.SetRowSpan(button4,2);
}