[UWP]从代码更改按钮文本属性 [英] [UWP]Change Button Text Properties from code

查看:68
本文介绍了[UWP]从代码更改按钮文本属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我正在尝试更改UWP应用程序中文本文件的按钮文本属性。


我已经能够成功设置大多数属性但是我无法使Color属性起作用。


我需要从文件中读取颜色然后更改新颜色按钮的前景色。



例如: 

 

"大" :[

{
" FontSize" :40,
" FontFace" :"Helvetica",
" FontColor" :"黑色"
}

]

这是正在读取的JSON文件的片段。


我可以让Size和Face工作,但不能使用这个颜色:

 NameText.Text = labels。 ROOMNAME; 
NameText.FontSize = _font.HeaderFontSize_LG;
NameText.FontFamily = new FontFamily(_font.HeaderFontFace_LG);

buti无法使颜色生效。我已经谷歌搜索了几个小时,找不到可行的解决方案。


任何帮助将不胜感激。



解决方案

嗨CMCTS,


会不会这个解决方案适合你?


https://stackoverflow.com/questions/36077231/how-to-change-background-color-of-button-in-uwp-apps- in-c-sharp 


此致,


IoTGirl


Hello,

I am trying to change a buttons Text properties from a text file in a UWP application.

I have been able to set most properties successfully however I cannot get the Color property to work.

I need to read the color from file and then change the foreground color of the button from the new color.

For example: 

"Large" : [

{ "FontSize" : 40, "FontFace" : "Helvetica", "FontColor" : "Black" }

]

this is a snippet from the JSON file that is being read.

I can get the Size and Face to work but cant get the color to work with this:

 NameText.Text = labels.RoomName;
                NameText.FontSize = _font.HeaderFontSize_LG;
                NameText.FontFamily = new FontFamily(_font.HeaderFontFace_LG);

buti cannot get the color to work. I have been Googling for hours and cannot find a working solution.

Any help would be greatly appreciated.

解决方案

Hi CMCTS,

Would this solution work for you?

https://stackoverflow.com/questions/36077231/how-to-change-background-color-of-button-in-uwp-apps-in-c-sharp 

Sincerely,

IoTGirl


这篇关于[UWP]从代码更改按钮文本属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆