Dua Ali
Dua Ali

Reputation: 3343

How to change Background color of TextBox?

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:

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

Upvotes: 1

Views: 6452

Answers (1)

Zbigniew
Zbigniew

Reputation: 27614

You need to use 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:

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

Upvotes: 7

Related Questions