如何在 WinRT 中将字符串颜色转换为画笔 [英] How do I convert a string color to a Brush in WinRT
本文介绍了如何在 WinRT 中将字符串颜色转换为画笔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
似乎 ConvertFromString 从 WinRT 中消失了.所以我很难找到在组合框中获取字符串并使用它设置文本前景和网格背景的方法.
It seems like ConvertFromString is gone from WinRT. So I am having trouble finding a way to take a string in a combobox and using it set text foreground and a grid's background.
这是我最近的尝试
private void ColorDropBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
string backGroundColor = e.ToString();
SolidColorBrush newcolor = new SolidColorBrush();
newcolor = backGroundColor as SolidColorBrush;
this.ContentRoot.Background = newcolor;
}
有什么建议/解决方法吗?
Any suggestions/workarounds?
推荐答案
库中没有提供转换.但是,转换例程编写起来很简单,例如 http://blog.lookitskris.com 中提到的那个/?p=22.
There is no conversion supplied in the library. However, conversion routines are simple to write, such as the one mentioned in http://blog.lookitskris.com/?p=22.
这篇关于如何在 WinRT 中将字符串颜色转换为画笔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文