动画代码:

 xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="FocusStateGroup">
<vsm:VisualState x:Name="Focus">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.95" KeySpline="0,0,0.5,1"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value=""/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.95" KeySpline="0,0,0.5,1"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value=""/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="Unfocus">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.95" KeySpline="0,0,0.5,1"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value=""/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.95" KeySpline="0,0,0.5,1"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value=""/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
</vsm:VisualStateManager.VisualStateGroups>

后台代码触发动画,并让其从第一个状态过渡到第二个状态

private void AddContactButton_MouseEnter(object sender, MouseEventArgs e)
{
VisualStateManager.GoToState(this, "Focus", true);
} private void AddContactButton_MouseLeave(object sender, MouseEventArgs e)
{
VisualStateManager.GoToState(this, "Unfocus", true);
} protected void InitEvents()
{
base.MouseEnter+=(new MouseEventHandler(this.AddContactButton_MouseEnter));
base.MouseLeave+=(new MouseEventHandler(this.AddContactButton_MouseLeave));
}

silverlight控件动画状态的过渡的更多相关文章

  1. Windows Store App 控件动画

    在开发Windows应用商店应用时,开发工具中已经封装了大量的控件供开发人员使用,而其中有一部分控件,例如FlipView.ToolTip.ListView以及SemanticZoom等控件中已经默认 ...

  2. (转)Silverlight控件关系理解

    原文地址http://www.cnblogs.com/Joetao/articles/1899664.html 本篇学习了Silverlight中的控件继承关系,了解控件的继承关系对应我们操作控件,使 ...

  3. 仿酷狗音乐播放器开发日志二十三 修复Option控件显示状态不全的bug(附源码)

    转载请说明原出处,谢谢~~ 整个仿酷狗工程的开发将近尾声,现在还差选项设置窗体的部分,显然在设置窗体里用的最多的就是OptionUI控件,我在写好大致的布局后去测试效果,发现Option控件的显示效果 ...

  4. Android自己定义控件(状态提示图表)

    [工匠若水 http://blog.csdn.net/yanbober 转载烦请注明出处.尊重分享成果] 1 背景 前面分析那么多系统源代码了.也该暂停下来歇息一下,趁昨晚闲着看见一个有意思的需求就操 ...

  5. silverlight 控件样式动态绑定

    <telerik:RadDiagram x:Name="diagram1" GraphSource="{Binding GraphSource, Mode=TwoW ...

  6. silverlight控件阴影效果示例

    <ScrollViewer MaxHeight="400" VerticalScrollBarVisibility="Auto" HorizontalSc ...

  7. silverlight 控件自定义样式 实现方法

    1:在app.xaml中加入需实现的样式,如: <Application.Resources> <Style x:Key="NodeStyle" TargetTy ...

  8. Android 开发学习进程0.15 adb cardview framelayout 控件设置状态获取焦点

    Android设备调试桥 即adb 使用adb进行无线调试的一些常用命令 adb tcpip 5555 设置调试端口为5555 防止冲突 adb shell ifconfig wlan0 查询局域网中 ...

  9. Silverlight控件——如何提升应用程序信任度与问题解决

    从silverlight5开始,可以在项目设置中勾选“在浏览器内运行时需要提升的信任”来达到在浏览器内运行提权silverlight客户端的目的,在个特性很有用处. 可我使用这个功能时遇到了一个奇怪的 ...

随机推荐

  1. HTML网页制作:[12]使用框架结构之frameset

    首先,我希望在你的目录下,有4个网页,各自显示不同的内容. 如图所示: 1.html显示“火影忍者” 2.html显示“英雄联盟” 3.html显示“嵌入式开发.网页开发.安卓开发” 4.html显示 ...

  2. 去掉UItableview headerview黏性

    //去掉UItableview headerview黏性 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (scrollView ...

  3. spring中的定时任务调度用例

    在application-quartz.xml配置文件中添加如下配置信息: <!-- Quartz -->     <bean id="getSendEmailObject ...

  4. contact表单错误解决记录

    在上篇表单验证中,过程中可谓坎坷,记录一下错误问题及解决方案. 我们用到的模板contact_form.html如下,其他urls.py自行去修改. <html> <head> ...

  5. 高性能PHP论坛 Carbon Forum

    Carbon Forum,一个高性能的.高安全性的.基于话题的PHP轻论坛. 优秀的架构,高效的代码,每个页面平均执行时间仅为1~5毫秒,同时恰当地使用异步加载技术,在SEO与用户体验间取得平衡. 论 ...

  6. Flink Program Guide (5) -- 预定义的Timestamp Extractor / Watermark Emitter (DataStream API编程指导 -- For Java)

    本文翻译自Pre-defined Timestamp Extractors / Watermark Emitter ------------------------------------------ ...

  7. Laravel中的队列处理

    Laravel中的队列处理 队列介绍 为什么要有消息队?这里先对其进行一个简单的介绍,方便还不了解的同学理解.在面向对象里,有一个很简单的概念--消息传递,而消息队列就可以在它上面扩展一下,把它说的更 ...

  8. easyui的datagrid删除一条记录后更新出问题

    1.问题 如果先删除一条记录,然后不选中一条记录,去更新一条,默认是有选中的记录的,就是被删除的那条记录. 2.解决方法 $("#dg").datagrid('uncheckAll ...

  9. MVC 创建带图片的<A></A>标签

    <a href="@Url.Action("Detail", "Product", new { messageId = item.message ...

  10. Linux04--文本编辑器vim

    1.Linux系统下常用的文本编辑器介绍 •  命令行方式      vi/vim: 类UNIX操作系统中常用的内置编辑器,习惯操作后功能强大.      pico或nano:一种风格很像Micros ...