时间: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常用功能

    1.复制文件 private void fileChannelCopy(File source, File target) throws IOException { FileInputStream f ...

  2. K好数

    有点坑 在他这里 0不算一位数 #include <iostream> #include <cstdio> #include <string.h> using na ...

  3. Python: 合并拼接字符串join()| format() | +

    将几个小字符串合并成为一个大的字符串 1如果合并的是一个序列,最快的方式是使用join()方法 >>> parts = ['Is', 'Chicago', 'Not', 'Chica ...

  4. linux centos系统下升级python版本

    本文参考资料:https://www.cnblogs.com/leon-zyl/p/8422699.html,https://blog.csdn.net/tpc1990519/article/deta ...

  5. 限制 input 输入框只能输入纯数字

    oninput = "value=value.replace(/[^\d]/g,'')"

  6. 使用Spring实现读写分离( MySQL实现主从复制)(转)

    本文转自:http://blog.csdn.net/jack85986370/article/details/51559232 1.  背景 我们一般应用对数据库而言都是“读多写少”,也就说对数据库读 ...

  7. svn忽略目录,svn忽略app目录add toignore list,避免每次更新很多app的内容下来导出到本地很麻烦

    svn忽略目录,svn忽略app目录add toignore list,避免每次更新很多app的内容下来导出到本地很麻烦 ------------------------------ 本人微信公众帐号 ...

  8. python中hasattr, getattr,setattr及delattr四个方法

    通过一个实例来说明,这四个函数的用法: 首先一个如下的一个简单的类: class Animal(object): def __init__(self,name, zone): self.name = ...

  9. 08: CORS实现跨域请求

    目录: 1.1 cors跨域请求介绍 1.2 使用tornado实现 复杂请求 1.3 Django中使用django-cors-headers解决跨域问题 1.1 cors跨域请求介绍返回顶部 1. ...

  10. 数据结构-队列(3)-使用Java内置队列

    大多数流行语言都提供内置的队列库,因此您无需重新发明轮子. 如前所述,队列有两个重要的操作,入队 enqueue 和出队 dequeue. 此外,我们应该能够获得队列中的第一个元素,因为应该首先处理它 ...