.Xaml不会渲染用代码编写的unicode吗?

use*_*857 1 c# unicode silverlight xaml windows-store-apps

在Windows应用商店的.xaml中,如果我这样写:

<TextBlock Text="&#x2606;" />
Run Code Online (Sandbox Code Playgroud)

它将渲染一颗星星。

但是,如果我用C#代码这样写:

TextBlock tb = new TextBlock
{
    Text = "&#x2606;"
};
Run Code Online (Sandbox Code Playgroud)

它不会渲染,为什么呢?如何呈现用C#代码编写的unicode?

Hen*_*man 5

&...;表示法是XML编码,没有对C#字符串进行解码。使用

TextBlock tb = new TextBlock
{
    Text = "\x2606";
    // Or just:
    // Text = "?";
};
Run Code Online (Sandbox Code Playgroud)