I need to change the row and column Together. Is this possible? I've searched but could not find an answer

        var da = new DoubleAnimation();
        da.From = 0;
        da.To = 2;
        da.Duration = new Duration(TimeSpan.FromSeconds(1));
        Soldier.BeginAnimation(Grid.RowProperty, da);
        Soldier.BeginAnimation(Grid.ColumnProperty, da);

xaml code:

   <Grid>
        <Grid Name="Grm" Width="500" Height="500" Background="#FF14831E">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="100"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="100"/>
                <RowDefinition Height="100"/>
                <RowDefinition Height="100"/>
                <RowDefinition Height="100"/>
                <RowDefinition Height="100"/>
            </Grid.RowDefinitions>
            <Image Name="Soldier" Grid.Row="0" Grid.Column="0" Source="Soldier-Red.png" Width="26" Height="34" MouseLeftButtonDown="Image_MouseLeftButtonDown_1"></Image>
        </Grid>
    </Grid>
1

There are 1 best solutions below

0
On BEST ANSWER

The RowProperty and ColumnProperty are Int32 properties, so you will have to use a Int32Animation

Example:

    var da = new Int32Animation();
    da.From = 0;
    da.To = 2;
    da.Duration = new Duration(TimeSpan.FromSeconds(1));
    Soldier.BeginAnimation(Grid.RowProperty, da);
    Soldier.BeginAnimation(Grid.ColumnProperty, da);