日期:2014-05-16 浏览次数:20947 次
Silverlight动画目标
Silverlight动画都是基于时间的,你只需指定特定时间段内需要发生的改变,Silverlight的动画类会自动处理好剩下的工作。
Silverlight的动画的运行原理是改变特定对象的特定属性,该属性(即动画目标)必须是依赖属性。
Silverlight动画可用于double、Color、Point和Object类型,下面是相应的动画类:
Object
DependencyObject(抽象)
Timeline(抽象)
DoubleAnimation
DoubleAnimationUsingKeyFrames
ColorAnimation
ColorAnimationUsingKeyFrames
PointAnimation
PointAnimationUsingKeyFrames
ObjectAnimationUsingKeyFrames
Storyboard -- 故事板
下面是一个DoubleAnimation示例:
xaml文件片段如下所示:
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            
            <Button Name="btn1"
                    Content="Button No. 1"
                    Grid.Row="0"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    RenderTransformOrigin="0.5 0.5"
                    Click="OnButtonClick">
                <Button.RenderTransform>
                    <RotateTransform x:Name="rotate1" />
                </Button.RenderTransform>
            </Button>
<Button Name="btn2"
                    Content="Button No. 2"
                    Grid.Row="1"
                    HorizontalAlignment="Center"