Silverlight(11) - 2.0动画之ColorAnimation, DoubleAnimation, PointAnimation, 内插关键帧动画
2008-11-14 11:50:32 来源:WEB开发网KeyFrame.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace Silverlight20.Animation
{
public partial class KeyFrame : UserControl
{
public KeyFrame()
{
InitializeComponent();
}
private void caRectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
caStoryboard.Begin();
}
private void daRectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
daStoryboard.Begin();
}
private void paPath_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
paStoryboard.Begin();
}
}
}
5、Programmatically.xaml
<UserControl x:Class="Silverlight20.Animation.Programmatically"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel HorizontalAlignment="Left">
<!--
MouseLeftButtonDown - 在该Canvas上单击鼠标后所执行的事件
-->
<Canvas x:Name="canvas" Background="Yellow" Width="640" Height="480" MouseLeftButtonDown="Canvas_MouseLeftButtonDown">
<Path Fill="Red">
<Path.Data>
<EllipseGeometry x:Name="ellipseGeometry" Center="200,100" RadiusX="15" RadiusY="15" />
</Path.Data>
</Path>
</Canvas>
<StackPanel.Resources>
<Storyboard x:Name="storyboard">
<PointAnimation
x:Name="pointAnimation"
Storyboard.TargetProperty="Center"
Storyboard.TargetName="ellipseGeometry"
Duration="0:0:2"/>
</Storyboard>
</StackPanel.Resources>
</StackPanel>
</UserControl>
Programmatically.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace Silverlight20.Animation
{
public partial class Programmatically : UserControl
{
public Programmatically()
{
InitializeComponent();
}
private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// 鼠标相对与canvas的坐标
double newX = e.GetPosition(canvas).X;
double newY = e.GetPosition(canvas).Y;
Point myPoint = new Point(newX, newY);
// 将动画的结束值设置为鼠标的当前坐标
pointAnimation.To = myPoint;
// 播放动画
storyboard.Begin();
}
}
}
OK
Tags:Silverlight 动画 ColorAnimation
编辑录入:爽爽 [复制链接] [打 印]- ››silverlight全屏显示图片
- ››动画制作之&按位AND 运算符
- ››动画* 、*= 乘法赋值运算符
- ››Silverlight MVVM 模式(一) 切近实战
- ››Silverlight for Windows Phone 7开发系列(1):...
- ››Silverlight for Windows Phone 7开发系列(2):...
- ››Silverlight for Windows Phone 7开发系列(3):...
- ››Silverlight for Windows Phone 7开发系列(4):...
- ››Silverlight for Symbian
- ››Silverlight3系列(四)数据绑定 Data Binding 1
- ››动画的前制与制程
- ››silverlight2 游戏 1 你能坚持多少秒
- 中查找“Silverlight(11) - 2.0动画之ColorAnimation, DoubleAnimation, PointAnimation, 内插关键帧动画”更多相关内容
- 中查找“Silverlight(11) - 2.0动画之ColorAnimation, DoubleAnimation, PointAnimation, 内插关键帧动画”更多相关内容
- 上一篇:Silverlight(12) - 2.0外观之样式, 模板, 视觉状态和视觉状态管理器
- 下一篇:Silverlight(10) - 2.0其它之Transform详解,以及UIElement和FrameworkElement的常用属性
更多精彩
赞助商链接