zoukankan      html  css  js  c++  java
  • wpf 窗体内容旋转效果 网摘

    <Window x:Class="simplewpf.chuangtixuanzzhuan"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="chuangtixuanzzhuan" Height="300" Width="300">
        <Grid Name="rectangle2">
            <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="29,67,0,0" Name="button2" VerticalAlignment="Top" Width="75" Click="button2_Click" Canvas.Left="21" Canvas.Top="0" />
            <Rectangle Height="71" HorizontalAlignment="Left" Margin="50,207,0,0"  Stroke="Black" VerticalAlignment="Top" Width="101" Fill="#FF967878" />
            <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="162,67,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click"  Canvas.Left="79" Canvas.Top="32" />
        </Grid>
    </Window>

    //后台代码

         private void button2_Click(object sender, RoutedEventArgs e)
            {
                RotateTransform rtf = new RotateTransform();
                rectangle2.RenderTransform = rtf;
                DoubleAnimation dbAscending = new DoubleAnimation(0, 360, new Duration(TimeSpan.FromSeconds(3)));
                Storyboard storyboard = new Storyboard();
                dbAscending.RepeatBehavior = RepeatBehavior.Forever;
                storyboard.Children.Add(dbAscending);
                Storyboard.SetTarget(dbAscending, rectangle2);
                Storyboard.SetTargetProperty(dbAscending, new PropertyPath("RenderTransform.Angle"));
                storyboard.Begin();
            }
          //  using System.Windows.Media.Animation;
            private void button1_Click(object sender, RoutedEventArgs e)
            {
                RotateTransform rtf = new RotateTransform();
                rectangle2.RenderTransform = rtf;
                DoubleAnimation dbAscending = new DoubleAnimation(0, 360, new Duration(TimeSpan.FromSeconds(3)));
                dbAscending.RepeatBehavior = RepeatBehavior.Forever;
                rtf.BeginAnimation(RotateTransform.AngleProperty, dbAscending);
            }

  • 相关阅读:
    js--事件--事件代理
    bind call apply 的区别和使用
    自己手动用原生实现bind/call/apply
    HLSL GLSL CG着色语言比较
    AABB和OBB包围盒简介
    BSTR LPSTR LPWSTR CString VARIANT COleVariant variant t CC
    UE4蓝图简介
    3D MAX脚本原理
    VC中GetLastError 获取错误信息的使用
    最强偏振3D播放器TriDef 3D安装+全格式播放配置
  • 原文地址:https://www.cnblogs.com/tianyiwuying/p/3264393.html
Copyright © 2011-2022 走看看