Silverlight开发实践--My Album(源)
2009-04-08 12:01:20 来源:WEB开发网其中利用了一些简单的变化效果。创建了第一个元素,接下来的11个元素基本上是一样的,要修改的就是相对于主Canves的位置和相应的x:Name的值。
然后就是给每一个图片对象添加4个Storyboard:
鼠标经过故事板,鼠标移出故事板,鼠标第一次单击故事板,鼠标再次单击故事板。
当然,这个工作最好用Blend来搞定。
<!--鼠标进入时,图片放大一倍-->
<Storyboard x:Name="mouseEnter0">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="album0"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"></SplineDoubleKeyFrame>
<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1.1"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="album0"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"></SplineDoubleKeyFrame>
<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1.1"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<!--鼠标移出时,图片变回原大小-->
<Storyboard x:Name="mouseLeave0">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="album0"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"></SplineDoubleKeyFrame>
<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="album0"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"></SplineDoubleKeyFrame>
<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<!--鼠标左键单击时,设置图片为画布大小-->
<Storyboard x:Name="PicZoomIn0">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="album0" Duration="00:00:00.0010000"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1.1"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="album0" Duration="00:00:00.0010000"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1.1"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="album0"
Storyboard.TargetProperty="(FrameworkElement.Width)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="170"></SplineDoubleKeyFrame>
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="300"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="album0"
Storyboard.TargetProperty="(FrameworkElement.Height)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="130"></SplineDoubleKeyFrame>
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="300"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Image0"
Storyboard.TargetProperty="(FrameworkElement.Width)">
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="300"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Image0"
Storyboard.TargetProperty="(FrameworkElement.Height)">
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="300"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<!--鼠标再次单击是,图片变回原来大小-->
<Storyboard x:Name="PicZoomOut0">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="album0" Duration="00:00:00.0010000"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1.1"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="album0" Duration="00:00:00.0010000"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1.1"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="album0"
Storyboard.TargetProperty="(FrameworkElement.Width)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="170"></SplineDoubleKeyFrame>
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="170"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="album0"
Storyboard.TargetProperty="(FrameworkElement.Height)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="130"></SplineDoubleKeyFrame>
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="130"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Image0"
Storyboard.TargetProperty="(FrameworkElement.Width)">
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="160"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Image0"
Storyboard.TargetProperty="(FrameworkElement.Height)">
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="120"></SplineDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
Tags:Silverlight 开发 实践
编辑录入:爽爽 [复制链接] [打 印]- ››开发Android 日历教程
- ››开发学院总结 Win 8实用技巧大全
- ››开发学院原创教程:把win8的IE10放桌面上方法(非...
- ››silverlight全屏显示图片
- ››Silverlight MVVM 模式(一) 切近实战
- ››开发者眼中的Windows Phone和Android
- ››开发学院教你用SQL 语句最快速清空MySQL 数据表的...
- ››Silverlight for Windows Phone 7开发系列(1):...
- ››Silverlight for Windows Phone 7开发系列(2):...
- ››Silverlight for Windows Phone 7开发系列(3):...
- ››Silverlight for Windows Phone 7开发系列(4):...
- ››开发一个自己的HTML在线编辑器(一)
更多精彩
赞助商链接