我正在寻找一种方法来更改 C# 中的 Grid.column 和 Grid.Row Xaml 值,但我不知道如何更改这是我的 Xaml 代码:<StackLayout HorizontalOptions="FillAndExpand" Orientation="Horizontal" VerticalOptions="FillAndExpand" Grid.Row="1" > <Label FontSize="27" Text="⦿" TextColor="White" x:Name="otherbookslabel" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" > <Label.GestureRecognizers> <TapGestureRecognizer Tapped="OnOtherNews" /> </Label.GestureRecognizers> </Label> <Grid RowSpacing="5" ColumnSpacing="5" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" x:Name="MainGridNews" > <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="*" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <StackLayout Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" BackgroundColor="AliceBlue" x:Name="GridRectangle" ></StackLayout> <StackLayout Grid.Row="1" Grid.Column="0" BackgroundColor="Beige" x:Name="GridCarreGaucheMilieu" ></StackLayout> <StackLayout Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" BackgroundColor="Accent" x:Name="GridCarreDroiteBas" ></StackLayout> <StackLayout Grid.Row="2" Grid.Column="0" BackgroundColor="OldLace" x:Name="GridCarreGaucheBas" ></StackLayout> </Grid> </StackLayout>我在 C# 中启动了该函数: public void OnOtherNews(object sender, EventArgs e) { }在此先感谢您的帮助
1 回答
胡说叔叔
TA贡献1804条经验 获得超8个赞
删除它,然后将其重新添加到新位置
myGrid.Children.Remove(myElement); myGrid.Children.Add(myElement, col, row);
- 1 回答
- 0 关注
- 132 浏览
添加回答
举报
0/150
提交
取消