tags:

views:

161

answers:

2

Hi 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

A: 

Hi,
Use the Grid Controls ColumnProperty and RowProperty like this,

label.SetValue(Grid.ColumnProperty, 0);
label.SetValue(Grid.RowProperty,0);


HTH

Best Regards
Anand

Anand
+1  A: 

In addition to Anand's answer, you can also do it like that :

Grid.SetColumn(label, 0);
Grid.SetRow(label, 0);
Thomas Levesque