如何使文本块的文本的某些部分变为粗体? [英] How to make some part of text block's text as bold ?

查看:209
本文介绍了如何使文本块的文本的某些部分变为粗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要输出为"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!

推荐答案

在xaml之后结帐,希望这会提供一些指导到你

Checkout following xaml hope this will provide some guidlines to u

<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>


请仔细阅读一次

将文本的某些部分设为粗体 [
Hi please go thorough it once

make some part of text as bold[^]


<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>


这篇关于如何使文本块的文本的某些部分变为粗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆