Reputation: 16903
I have a xaml code like this
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="100"/>
</Grid.RowDefinitions>
<Label Content="Test" Grid.Column="1" Grid.Row="1" Height="100" Width="100" FontSize="20" Name="label"/>
<Button Content="Change" Grid.Column="0" Grid.Row="0" Click="Button_Click" />
</Grid>
How to change the position of the label when I click on the button. ie, change the row and column of the label.
Thanks
Upvotes: 1
Views: 4472
Reputation: 14913
Use the Grid Controls ColumnProperty and RowProperty like this:
label.SetValue(Grid.ColumnProperty, 0);
label.SetValue(Grid.RowProperty,0);
Upvotes: 1
Reputation: 292355
In addition to Anand's answer, you can also do it like that :
Grid.SetColumn(label, 0);
Grid.SetRow(label, 0);
Upvotes: 3