<script language='javascript' src='http://www.shiqiaotou.com/donetk/Header.js'></script>
WPF中的动画
周银辉
动画无疑是WPF中最吸引人的特色之一,其可以像Flash一样平滑地播放并与程序逻辑进行很好的交互。这里我们讨论一下故事板。
在WPF中我们采用Storyboard(故事板)的方式来编写动画,为了对Storyboard有个大概的印象,你可以粘贴以下代码到XamlPad来查看效果:
周银辉
动画无疑是WPF中最吸引人的特色之一,其可以像Flash一样平滑地播放并与程序逻辑进行很好的交互。这里我们讨论一下故事板。
在WPF中我们采用Storyboard(故事板)的方式来编写动画,为了对Storyboard有个大概的印象,你可以粘贴以下代码到XamlPad来查看效果:
<!--
This example shows how to animate with a storyboard.
-->
< Page xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle ="Storyboards Example" >
< StackPanel Margin ="20" >
< Rectangle Name ="MyRectangle"
Width ="100"
Height ="100" >
< Rectangle .Fill >
< SolidColorBrush x:Name ="MySolidColorBrush" Color ="Blue" />
</ Rectangle.Fill >
< Rectangle .Triggers >
< EventTrigger RoutedEvent ="Page.Loaded" >
< BeginStoryboard >
< Storyboard RepeatBehavior ="Forever" AutoReverse ="True" >
< DoubleAnimation
Storyboard.TargetName ="MyRectangle"
Storyboard.TargetProperty ="Width"
From ="100" To ="200" Duration ="0:0:1" />
</ Storyboard >
</ BeginStoryboard >
</ EventTrigger >
</ Rectangle.Triggers >
</ Rectangle >
</ StackPanel >
</ Page >
文章来源于 http://www.cnblogs.com/zhouyinhui 版权归原作者所有<script language='javascript' src='http://www.shiqiaotou.com/donetk/Footer.js'></script>
< Page xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle ="Storyboards Example" >
< StackPanel Margin ="20" >
< Rectangle Name ="MyRectangle"
Width ="100"
Height ="100" >
< Rectangle .Fill >
< SolidColorBrush x:Name ="MySolidColorBrush" Color ="Blue" />
</ Rectangle.Fill >
< Rectangle .Triggers >
< EventTrigger RoutedEvent ="Page.Loaded" >
< BeginStoryboard >
< Storyboard RepeatBehavior ="Forever" AutoReverse ="True" >
< DoubleAnimation
Storyboard.TargetName ="MyRectangle"
Storyboard.TargetProperty ="Width"
From ="100" To ="200" Duration ="0:0:1" />
</ Storyboard >
</ BeginStoryboard >
</ EventTrigger >
</ Rectangle.Triggers >
</ Rectangle >
</ StackPanel >
</ Page >
文章来源于 http://www.cnblogs.com/zhouyinhui 版权归原作者所有<script language='javascript' src='http://www.shiqiaotou.com/donetk/Footer.js'></script>