日期:2014-05-16 浏览次数:21223 次
新建一个项目叫做:TestAnimation用来测试动画StoryBoard的使用。
在上面拖拽一个Button来做实验。
<Page
x:Class="TestAnimation.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestAnimation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Button" HorizontalAlignment="Left" Margin="200,100,0,0" VerticalAlignment="Top">
<Button.RenderTransform>
<ScaleTransform x:Name="st1">
</ScaleTransform>
</Button.RenderTransform>
</Button>
</Grid>
</Page>
<Page.Resources>
<Storyboard x:Name="sb1">
<DoubleAnimation Storyboard.TargetName="st1"
Storyboard.TargetProperty="ScaleX" From="0" To="10">
</DoubleAnimation>
</Storyboard>
</Page.Resources>
private void Button_Click_1(object sender, RoutedEventArgs e)
{
sb1.Begin();
}当然,动画不仅仅局限于RenderTransform,也可以用在映射上。
<Page
x:Class="TestAnimation.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestAnimation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<Storyboard x:Name="sb1">
<DoubleAnimation Storyboard.TargetName="st1"
Storyboard.TargetProperty="ScaleX" From="0" To="10">
</DoubleAnimation>
</Storyboard>
<Storyboard x:Name="sb2">
<DoubleAnimation Storyboard.TargetName="pp1"
Storyboard.TargetProperty="RotationY" From="0" To="360">
</DoubleAnimation>
</Storyboard>
</Page.Resources>
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Button" HorizontalAlignment="Left" Margin="200,100,0,0" VerticalAlignment="Top" Click="Button_Click_1">
<Button.RenderTransform>
<Sc