时间:2011-06-15 21:26来源:百度空间 作者:shichen4 点击: 次

StoryBoard使用,Xaml转cs代码 Canvas.Triggers EventTriggerRoutedEvent= Image.MouseLeftButtonDown EventTrigger.Actions BeginStoryboard StoryboardStoryboard.TargetName= image1 Storyboard.TargetProperty= (Canvas.Left) DoubleAnimationAutoReverse= True Rep
  

  StoryBoard使用,Xaml转cs代码

<Canvas.Triggers>
                <EventTrigger RoutedEvent="Image.MouseLeftButtonDown">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard Storyboard.TargetName="image1" 
                                                Storyboard.TargetProperty="(Canvas.Left)" >
                                <DoubleAnimation AutoReverse="True" 
RepeatBehavior="Forever" 
                                                         BeginTime="0" 
Duration="0:0:20" From="0" To="-1100">
                                </DoubleAnimation>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Canvas.Triggers>

  转换为cs代码:

         this.image1.RenderTransform = new TranslateTransform();

this.image1.Name = "image1";
            NameScope.SetNameScope(this,new NameScope());
            this.RegisterName(this.image1.Name,this.image1);

DoubleAnimation xAnimation = new DoubleAnimation();
            xAnimation.From = 0;
            xAnimation.To = -1100;
            xAnimation.Duration = new Duration(TimeSpan.FromSeconds(30));

DependencyProperty[] propertyChain = new DependencyProperty[]
            {
                Image.RenderTransformProperty,
                TranslateTransform.XProperty
            };

Storyboard story = new Storyboard();
            story.AutoReverse = true;
            story.RepeatBehavior = RepeatBehavior.Forever;
            story.Children.Add(xAnimation);

Storyboard.SetTargetName(xAnimation,this.image1.Name);
            Storyboard.SetTargetProperty(xAnimation,new PropertyPath("(0).(1)",propertyChain));

story.Begin(this);

WPF StoryBoard用法的更多相关文章

  1. Wpf(Storyboard)动画简单实例

    原文:Wpf(Storyboard)动画简单实例 动画的三种变换方式 RotateTransform:旋转变换变化值:CenterX围绕转的圆心横坐标 CenterY纵坐标 Angle旋转角度(角度正 ...

  2. wpf Storyboard 不存在可解析名称“ ”的适用名称领域 No applicable name scope exists to resolve the name

    原文:wpf Storyboard 不存在可解析名称“ ”的适用名称领域 No applicable name scope exists to resolve the name 写了一个 Storyb ...

  3. WPF DataTriger 用法示例代码

    用法1: <DataGridTemplateColumn Header="{lex:LocText ExamineRoom}"> <DataGridTemplat ...

  4. WPF Storyboard 动画播放完毕时触发的事件

    /*故事版*/ Storyboard ClSto2; public PopUpWindow() { /*播放完毕,将当前窗体关闭*/ ClSto2.Completed += (s, e) => ...

  5. 【转】【WPF】WPF绑定用法

    一.简介 为了后面行文顺利,在进入正文之前,我们首先对本文所涉及到的绑定知识进行简单地介绍.该节包含绑定的基本组成以及构建方式. WPF中的绑定完成了绑定源和绑定目标的联动.一个绑定常常由四部分组成: ...

  6. (WPF)Storyboard

    Storyboard是一个为其所包括的动画提供目标信息的容器. 除非动画放在Storyboard中,负责不能在XMAL中被实例化. BeginStoryboard通过将Storyboard加入到触发器 ...

  7. WPF ICommand 用法

    基础类,继承与ICommand接口 using System; using System.Collections.Generic; using System.Linq; using System.Te ...

  8. WPF DataGrid 用法

    XAML==> <Window x:Class="QueueSystem.MainWindow" xmlns="http://schemas.microsof ...

  9. WPF中StringFormat 格式化 的用法

    原文 WPF中StringFormat 格式化 的用法 网格用法 <my:DataGridTextColumn x:Name="PerformedDate" Header=& ...

随机推荐

  1. Java性能优化——HashCode的使用

    背景 告警子系统监控4万个大网元所有端口的某些指标数据,根据阈值配置判断是否产生告警.采集——数据处理子系统每5分钟会主动采集24万次数据,发送24万条消息给告警子系统,这24万条消息涉及100万实体 ...

  2. linux常用命令:route 命令

    Linux系统的route 命令用于显示和操作IP路由表(show / manipulate the IP routing table).要实现两个不同的子网之间的通信,需 要一台连接两个网络的路由器 ...

  3. 50道JavaScript基础面试题(附答案)

    https://segmentfault.com/a/1190000015288700 1 介绍JavaScript的基本数据类型 Number.String .Boolean .Null.Undef ...

  4. python之路----线程

    线程概念的引入背景 进程 程序并不能单独运行,只有将程序装载到内存中,系统为它分配资源才能运行,而这种执行的程序就称之为进程.程序和进程的区别就在于:程序是指令的集合,它是进程运行的静态描述文本:进程 ...

  5. Google's Machine Learning Crash Course #03# Reducing Loss

    Goal of training a model is to find a set of weights and biases that have low loss, on average, acro ...

  6. python中递归调用

    递归一个通俗的解释就是,在函数中调用函数本身:伪代码如下: In [31]: def fun(): ....: fun() # 这个递归没有任何作用,只是为了说明什么是递归 递归(Recursion) ...

  7. RSA加解密用途简介及java示例

    在公司当前版本的中间件通信框架中,为了防止非授权第三方和到期客户端的连接,我们通过AES和RSA两种方式的加解密策略进行认证.对于非对称RSA加解密,因为其性能耗费较大,一般仅用于认证连接,不会用于每 ...

  8. Python descriptor 以及 内置property()函数

    Python Descriptor  1, Python Descriptor是这样一个对象 它按照descriptor协议, 有这样的属性之一 def __get__(self, obj, type ...

  9. Python 技术点

    1.文件操作 1-1 遍历文件夹和文件 import os rootDir = "/path/to/root" for parent, dirnames, filenames in ...

  10. 2018-2019-1 1723《程序设计与数据结构》第5&6&7周作业 总结

    作业地址 第五周作业: 提交情况如图: 第六周作业: 提交情况如图: 第七周作业: 提交情况如图: 作业问题 很多看上写的比较详细并且语言组织的也不错,我就这么随手一百度,搜出来了很多篇博客.(无奈) ...