5

我需要使用Storyboard. 写自己的动画是最好的选择吗?

4

1 回答 1

8

不,使用标准 XAML 很有可能:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" x:Name="col0"/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Grid.Resources>
        <Storyboard x:Key="sbCol0ToAuto">
            <ObjectAnimationUsingKeyFrames 
                BeginTime="0" Duration="0"
                Storyboard.TargetName="col0" Storyboard.TargetProperty="Width">
                <DiscreteObjectKeyFrame KeyTime="0">
                    <DiscreteObjectKeyFrame.Value>
                        <GridLength>*</GridLength>
                     </DiscreteObjectKeyFrame.Value>
                </DiscreteObjectKeyFrame>
             </ObjectAnimationUsingKeyFrames>
         </Storyboard>
    </Grid.Resources>
...
</Grid>

甚至更容易回到 Auto:

<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static GridLength.Auto}">
于 2010-02-11T06:08:05.147 回答