将XAML中的字体真棒字符绑定到文本 [英] binding font-awesome character in XAML to Text
本文介绍了将XAML中的字体真棒字符绑定到文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个TextBlock,我试图将文本绑定到超棒的字符以用作复选框.我有一个返回字符串的属性,但似乎有些东西将其转换为字符串而不是字符.
I have an TextBlock and I am trying to bind the text to a font-awesome character to use as a checkbox. I have a property that is returning a character string, but it seems that something is converting it to a string instead of a character.
这有效并绘制了一个复选框:
This works and draws a checkbox:
<TextBlock Text="" FontFamily="/Resources/fontawesome-webfont.ttf#FontAwesome" />
此组合不能:
public class myObject
{
public string MyString
{
get { return "" }
}
}
<TextBlock Text{Binding MyString} FontFamily="/Resources/fontawesome-webfont.ttf#FontAwesome" />
相反,它会绘制实际的字符串(使用#xf096;等),就好像它已被转义一样.
Instead, it draws the actual string (with the #xf096; et al) as if it were escaped.
有什么想法为什么或如何使它返回未加引号的字符?
Any ideas why or how to make this return the unquoted character?
谢谢!
推荐答案
查看全文