• WPF 用代码设置颜色


    纯色: 

    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; 

    下面是一个换肤界面的教程:

    http://www.cnblogs.com/zhouyinhui/archive/2007/08/02/840326.html

  • 相关阅读:
    美化博客园
    ansible的安装
    面向对象和类
    函数知识分类
    生成器
    内置函数_old
    迭代器
    装饰器
    Hadoop——MapReduce
    Hadoop——HDFS
  • 原文地址:https://www.cnblogs.com/keung/p/2937600.html
Copyright © 2020-2023  润新知