How to set a background color of a control in windows 8 store application

允我心安 提交于 2019-12-25 06:39:18

问题


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:


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;


来源:https://stackoverflow.com/questions/32968550/how-to-set-a-background-color-of-a-control-in-windows-8-store-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!