• WPF(三)控件2.背景画刷和前景画刷


      所有控件都包含背景和前景属性,设置Background和Foreground的值改变背景或前景颜色。

    1.使用代码设置颜色

                button1.Background = new SolidColorBrush(Colors.Blue);

    button2.Background = new SolidColorBrush(SystemColors.ControlColor);
    //button2.Background = SystemColors.ControlBrush;
    //button2.Background = new SolidColorBrush(Color.FromRgb(0,255,0));

    2.XAML中设置颜色

        <Grid>
    <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="59,12,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
    <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="156,12,0,0" Name="button2" VerticalAlignment="Top" Width="75" />
    <Button Content="Button" Background="Red" Height="23" HorizontalAlignment="Left" Margin="59,68,0,0" Name="button3" VerticalAlignment="Top" Width="75" />
    <Button Content="Button" Height="23" HorizontalAlignment="Right" Margin="0,68,107,0" Name="button4" VerticalAlignment="Top" Width="75" Click="button4_Click">
    <Button.Background>
    <SolidColorBrush Color="Blue"/>
    </Button.Background>
    </Button>
    </Grid>



  • 相关阅读:
    discuz制作
    Cookie和Session专题
    ecmall二次开发 直接实例化mysql对象
    ecmall widgets 挂件开发详解
    都是iconv惹的祸
    discuz+ecmall+phpcms整合
    replace into
    权限管理设计二
    权限管理设计一
    SVN服务器搭建和使用(二)
  • 原文地址:https://www.cnblogs.com/WilliamJiang/p/2355115.html
Copyright © 2020-2023  润新知