DoubleAnimation 故事板

前台代码:

<UserControl x:Class="story.MainPage"
    xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="
http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="
http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources >
        <Storyboard x:Name="sb">
            <DoubleAnimation Storyboard.TargetName="rtf" Storyboard.TargetProperty="Angle"  Duration="00:00:03" From="0" To="300"></DoubleAnimation>
        </Storyboard>
    </UserControl.Resources>
        <Grid x:Name="LayoutRoot" Background="White">
        <Image Name="img" Width="300" Height="300" Source="img/9.jpg" Stretch="Uniform"  >
            <Image.RenderTransform >
                <RotateTransform x:Name="rtf"></RotateTransform>
            </Image.RenderTransform>
        </Image>
        <Button Name="btn" Width="100" Height="50" FontSize="24" Content="故事板" Click="btn_Click"></Button>
    </Grid>
</UserControl>

DoubleAnimation 故事板_第1张图片

 

我们只需在后台加一句代码就行了:

 private void btn_Click(object sender, RoutedEventArgs e)
        {
            sb.Begin();
        }



原文链接: http://blog.csdn.net/mypc2010/article/details/7946464

你可能感兴趣的:(DoubleAnimation 故事板)