wpf 如何更改文本框的背景颜色?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17408406/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 09:07:05  来源:igfitidea点击:

How to change Background color of TextBox?

c#.netwpf

提问by Dua Ali

I am working on WPF, I want to change Background---color of textbox ( txtStatus.Background= white), but it is giving ERROR. Here my code is:

我正在研究 WPF,我想更改背景---文本框的颜色(txtStatus.Background= 白色),但它给出了错误。这里我的代码是:

public Window2()
            {
                InitializeComponent();
                txtStatus.Text = "Current Operation: NULL";
                txtStatus.Background= white
            }

回答by Zbigniew

You need to use Brushes:

您需要使用Brushes

txtStatus.Foreground = Brushes.White;

It contains a lot of colors, though if you want to use aRGB values then you can do it like this:

它包含很多颜色,但如果你想使用 aRGB 值,那么你可以这样做:

txtStatus.Foreground = new SolidBrush(Color.FromArgb(255, 0, 0, 255));