How to set a background color of a control in wind

2019-09-12 04:32发布

I am designing an application and had to instantiate controls via code. The problem is that I am unable to change the background color. I tried to look all over the internet, but no succes. I have contacted the Microsoft support service, but no succes either.

I read that you normally change a color by using System.Color or System.ColorHelper. Both are not accesible in the application.

So how to solve the following problem:

TextBox^ txtID = ref new TextBox();
txtID->Background = ?; 

1条回答
何必那么认真
2楼-- · 2019-09-12 05:33

I have the solution, first make a brush object and set the color and assign that color to your controls background. I used the following:

SolidColorBrush^ myBrush = ref new SolidColorBrush(Windows::UI::Colors::Red);
TextBox^ txtID = ref new TextBox();
txtID->Background = myBrush;
查看更多
登录 后发表回答