基于WPF实现控件轮廓跑马灯动画效果

代码如下

一、创建EdgeLight.xaml代码如下。


    
        
    

    
        
        
        
        
        
        
        
            
                
                    
                        
                            
                            
                            
                            
                        
                    
                    
                        
                            
                                
                                    
                                
                            
                            
                                
                                    
                                
                            
                            
                                
                                    
                                
                            
                            
                                
                                    
                                
                            
                        
                        
                    
                   
                    
                        
                            
                                
                            
                            
                                
                            
                        
                    
                
            
        
    


二、EdgeLight.cs代码如下。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace WPFDevelopers.Controls
{
    public class EdgeLight:ContentControl
    {
        public bool IsAnimation
        {
            get { return (bool)GetValue(IsAnimationProperty); }
            set { SetValue(IsAnimationProperty, value); }
        }

        public static readonly DependencyProperty IsAnimationProperty =
            DependencyProperty.Register("IsAnimation", typeof(bool), typeof(EdgeLight), new PropertyMetadata(false));



        public double LineSize
        {
            get { return (double)GetValue(LineSizeProperty); }
            set { SetValue(LineSizeProperty, value); }
        }

        public static readonly DependencyProperty LineSizeProperty =
            DependencyProperty.Register("LineSize", typeof(double), typeof(EdgeLight), new PropertyMetadata(1.0d));


        static EdgeLight()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(EdgeLight), new FrameworkPropertyMetadata(typeof(EdgeLight)));
        }

       

    }
}

三、新建EdgeLightExample.cs代码如下。


    
        
            
                
            
            
                
            
        
    


效果预览

基于WPF实现控件轮廓跑马灯动画效果_第1张图片

到此这篇关于基于WPF实现控件轮廓跑马灯动画效果的文章就介绍到这了,更多相关WPF跑马灯动画内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

你可能感兴趣的:(基于WPF实现控件轮廓跑马灯动画效果)