在xaml中格式化resourceDictionary中的文本
我的资源字典中有一个文本:在xaml中格式化resourceDictionary中的文本,xaml,formatting,resourcedictionary,Xaml,Formatting,Resourcedictionary,我的资源字典中有一个文本: <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"> &l
<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>
罗恩
请输入您的电子邮件。/system:String>
我通过以下方式将其绑定到xaml:
<TextBlock Text="{DynamicResource PersonalEmail}" Style="{DynamicResource TextBlockStyle}"/>
是否可以创建样式或转换器,以显示,例如,请粗体,其余文本正常显示?字符串本身不支持富文本格式,您可以使用来显示文本
<TextBlock>
<Span>
<Bold>Please</Bold> enter your email.
</Span>
</TextBlock>
谢谢你的回答。但是我想知道,如果使用
InlineCollections
的话,是否有一种实现动态资源存储的方法,似乎必须是StaticResource
DynamicSource
要求属性为DependencyProperty
。
<Window.Resources>
<Span x:Key="PersonalEmail">
<Bold>Please</Bold> enter your email.
</Span>
</Window.Resources>
<Grid>
<TextBlock>
<StaticResource ResourceKey="PersonalEmail" />
</TextBlock>
</Grid>