我显示4个按钮,在Row = 0 / Column = 0,Row = 0 / Column = 1,Row = 1 / Column = 0,Row = 1 / Column = 1,我想看到3个按钮同等服用。我正在使用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>
动态变化我希望在删除一个按钮后重新排列网格
private void Button_Clicked(object sender, EventArgs e)
{
grid.Children.RemoveAt(1);
}
任何人都可以提出您的想法
答案 0 :(得分:0)
单击按钮时,即可删除其中一个网格内容。它需要自动重新排列。为了实现上述场景,需要使用SetRowSpan和SetRow重新排列布局。
private void Button_Clicked(object sender, EventArgs e)
{
grid.Children.RemoveAt(1);
Grid.SetRowSpan(button4,2);
}