我正在用一堆system:string创建一个资源字典,我可以用DynamicResource调用它。我试图用不同的颜色突出显示字符串中的某些文本,这样我就不需要做太多的“运行文本”
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:System;assembly=mscorlib">
<Image.ToolTip>
<ToolTip BorderBrush="LightGoldenrodYellow" BorderThickness="1" Background="Black">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="LightGoldenrodYellow" FontSize="14" FontWeight="Bold">
<Run Text="{DynamicResource Example}"/>
<Run Text="{DynamicResource Example1}" FontStyle="Italic" FontSize="12" FontWeight="Normal"/>
</TextBlock>
</ToolTip>
</Image.ToolTip>
<s:String x:Key="Example" xml:space="preserve">Lucky Dice</s:String>
<s:String x:Key="Example1" xml:space="preserve"> Has a 30% chance to get an extra item.</s:String>
</ResourceDictionary>
<s:String x:Key="Example" xml:space="preserve"> Has a <Font color=red>30%</font> chance to get an extra item.</s:String>