码迷,mamicode.com
首页 > 其他好文 > 详细

WPF 画刷应用

时间:2014-09-16 12:31:40      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:blog   color   io   ar   strong   for   div   art   sp   

纯色: 

SolidColorBrush brush = new SolidColorBrush(Colors.White);
window1.Background = brush;

 

渐变色:

LinearGradientBrush buttonBrush = new LinearGradientBrush(); 
buttonBrush.StartPoint = new Point(0, 0.5); 
buttonBrush.EndPoint = new Point(1, 0.5); 
buttonBrush.GradientStops.Add(new GradientStop(Colors.Green, 0)); 
buttonBrush.GradientStops.Add(new GradientStop(Colors.White, 0.9)); 

 

图片: 

textBlock1.Background = new ImageBrush(new BitmapImage(new Uri(@"../Image/Bg.png", UriKind.RelativeOrAbsolute)));

 

如何将图片设置为窗体的背景:

System.Drawing.Bitmap bitmap = global::WpfApplication1.Properties.Resources.bg;
ImageSourceConverter convert = new ImageSourceConverter();
System.IO.MemoryStream ms = new System.IO.MemoryStream();
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
ImageBrush b = new ImageBrush();
b.ImageSource = (ImageSource)convert.ConvertFrom(ms);
this.Background = b; 

WPF 画刷应用

标签:blog   color   io   ar   strong   for   div   art   sp   

原文地址:http://www.cnblogs.com/NEIL-X/p/3974468.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!