3

我需要一起更改行和列。这可能吗?我已经搜索但找不到答案

        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);

xml代码:

   <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>
4

1 回答 1

2

RowPropertyandColumnProperty是属性,因此Int32您必须使用Int32Animation

例子:

    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);
于 2013-08-23T05:09:11.810 回答