Search code examples
wpfxamltextblock

Set/change text weight within the Text property of a TextBlock


I would like to be able to change the weight of text (e.g. change from Normal to Bold and back again) within the Text property string of a TextBlock (presumably using some control character set). Is this even possible?


Solution

  • TextBLock.Text creates a single Run, you set custom Inlines instead:

    <TextBlock>
        Text with <Bold>bold</Bold> within.
    <TextBlock>
    

    Obviously it no longer uses the Text property.