将XAML中的字体真棒字符绑定到文本 [英] binding font-awesome character in XAML to Text

查看:74
本文介绍了将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="&#xf096;" FontFamily="/Resources/fontawesome-webfont.ttf#FontAwesome" />

此组合不能:

public class myObject 
{
    public string MyString
    {
        get { return "&#xf096;" }
    }
}

<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?

谢谢!

推荐答案

使用

然后,即使由Binding提供,也会处理字符串. 我在台式机上对其进行了测试,但我认为这在手机版本上也应如此.

Then the string is processed even when provided by Binding. I tested it on desktop but I think this should work likewise on phone version.

这篇关于将XAML中的字体真棒字符绑定到文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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