如何在Application.Resources中标记字符串

时间:2014-09-04 20:57:12

标签: c# wpf xaml

我已经知道如何在wpf中执行此操作

<TextBlock HorizontalAlignment="Left" Margin="359,10,0,0" 
           TextWrapping="Wrap" VerticalAlignment="Top" Width="75">
    <Run>X</Run>
    <Run BaselineAlignment="Superscript" FontSize="8">4</Run>
</TextBlock>

this answer,或代码

string area;
area = "mm\xB2";
testTblock.Text = area;

但是你如何在Application.Resources中做到这一点?如

<Application.Resources>
<System:String x:Key="area">
     //what should be here?
</System:String>

以便我可以将它作为

应用于DynamicResource
<TextBlock Text="{DynamicResource area}" />

1 个答案:

答案 0 :(得分:0)

在文本值中使用十六进制值编码:

<system:String x:Key="myValue">
    mm&#xB2;
</system:String>