本文介绍了如何使文本块的文本的某些部分变为粗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
需要输出为"Hi Welcome MYNAME"
MYNAME为粗体.
我通过属性将此文本绑定到TextBlock.[Text ="{Binding MyProperty}"]
我的问题是,如何使文本的特定部分从显示时的属性变为粗体!
Need Output as "Hi Welcome MYNAME"
MYNAME as bold.
I am binding this text to the TextBlock through a property.[Text="{Binding MyProperty}" ]
My question is, How can i make a specific part of a Text coming form the property to be bold while displaying!
推荐答案
<grid x:name="LayoutRoot" background="White" xmlns:x="#unknown">
<textblock fontfamily="Arial" width="400">
<linebreak />
<run foreground="Maroon" fontfamily="Courier New" fontsize="24">
Sample
</run>
<linebreak />
<run foreground="Teal" fontfamily="Times New Roman" fontsize="18" fontstyle="Italic">
Text
</run>
<linebreak />
<run foreground="SteelBlue" fontfamily="Verdana" fontsize="14" fontweight="Bold">
Run
</run>
</textblock>
</grid>
<TextBlock >
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}{1}" " >
<Binding Path="Text" ElementName="txtTest" />
<Binding Path="Text" ElementName="txtTest1" />
</MultiBinding>
</TextBlock.Text>
<TextBox x:Name="txtTest" FontWeight="Bold" Text="{Binding MyPropert1}"></TextBox>
<TextBox x:Name="txtTest1" Text="{Binding MyPropert2}"></TextBox>
</TextBlock>
这篇关于如何使文本块的文本的某些部分变为粗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!