Reputation: 475
I am looking for a way to change my Grid.column and my Grid.Row Xaml value from C# but I cannot see how
Here is my Xaml code :
<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>
I started the functiion in c#:
public void OnOtherNews(object sender, EventArgs e) {
}
Thanks in advance for your help
Upvotes: 1
Views: 1159
Reputation: 89204
remove it and then re-add it at the new position
myGrid.Children.Remove(myElement);
myGrid.Children.Add(myElement, col, row);
Upvotes: 2