WPF中定时器,颜色设置

定时器应用

1.引入:using System.Windows.Threading; // 定时器命名空间
2.初始化对象:DispatcherTimer moveTimer1 = new DispatcherTimer();
3.添加定时器事件:moveTimer1.Tick += MoveTimer1_Tick;
4.设置定时器频率:(以毫秒数):moveTimer1.Interval = TimeSpan.FromMilliseconds(100);

设置颜色

对象.Background=Brushes.颜色;

	BG.Background = Brushes.Red;

对象.Background = new LinearGradientBrush(); // 设置成线性渐变

BG.Background = new LinearGradientBrush(Colors.Yellow, Colors.Pink, 10);

对象.Background = new RadialGradientBrush();// 设置成径线渐变

BG.Background = new RadialGradientBrush(Colors.Red,Colors.Orange);

对象.Background = new SolidColorBrush(); // 纯色

BG.Background = new SolidColorBrush(Color.FromRgb(80,00,80));

后续持续更新

发布了117 篇原创文章 · 获赞 111 · 访问量 9658

猜你喜欢

转载自blog.csdn.net/dust__/article/details/103557729