在 xaml 中格式化来自 resourceDictionary 的文本

Format text from resourceDictionary in xaml

我的资源字典中有一段文字:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="ResourceDictionaryName" Localization.Comments="$Content(DoNotLocalize)">Loc-en-EN</system:String>

<!--MainControl.xaml-->   
<system:String x:Key="PersonalEmail">Please enter your email./system:String></ResourceDictionary>

我用这种方式将它绑定到 xaml:

   <TextBlock Text="{DynamicResource PersonalEmail}" Style="{DynamicResource TextBlockStyle}"/>

是否可以创建样式或转换器以显示,例如, 加粗,其余文本正常?

字符串本身不支持富文本格式,可以用一个Span来显示文本。

<TextBlock>
    <Span>
        <Bold>Please</Bold> enter your email.
    </Span>
</TextBlock>

您几乎可以将任何东西放入 ResourceDictionary 并给它一个密钥,然后使用该密钥引用它。

<Window.Resources>
    <Span x:Key="PersonalEmail">
        <Bold>Please</Bold> enter your email.
    </Span>
</Window.Resources>
<Grid>
    <TextBlock>            
        <StaticResource ResourceKey="PersonalEmail" />
    </TextBlock>
</Grid>