WpfApplication6/MainWindow.xaml.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication6
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
       
        
           
            //1、在类级别声明变量。(创建演示图板)
    private Storyboard myStoryboard;
        public MainWindow()
        {
            InitializeComponent();
            //后台的写法
            //实例化栈式面板
            StackPanel myPanel = new StackPanel();
            myPanel.Margin = new Thickness(10);//设置外边距
            //实例化矩形
            Rectangle myRectangle = new Rectangle();
            myRectangle.Name = "myRectangle";//设置矩形名称
            this.RegisterName(myRectangle.Name, myRectangle);//

            myRectangle.Width = 100;//宽度
            myRectangle.Height = 100;//高度
            myRectangle.Fill = Brushes.Blue;//填充色
            //2、创建 DoubleAnimation
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = 1.0;//开始值
            myDoubleAnimation.To = 0.0;//结束值
            //从其起始值到目标值需要5秒时间
            myDoubleAnimation.Duration = new
           Duration(TimeSpan.FromSeconds(5));
           //使元素消失后变为视野
           myDoubleAnimation.AutoReverse = true;
           //使动画无限重复
           myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
           //初始化 Storyboard 并添加动画作为其子级。
           myStoryboard = new Storyboard();
           myStoryboard.Children.Add(myDoubleAnimation);
            //指定要进行动画处理的对象,这里指定 myRectangle.Name
            Storyboard.SetTargetName(myDoubleAnimation,
           myRectangle.Name);
后面还有 20 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。