WPF - TextBlock - Format Text Programmatically

Viewed 29805

In the TextBlock object you can format the text in the XAML like this:

<TextBlock>
    <Bold>bold text</Bold> random non bold next
</TextBlock>

How do you do the "Bold" tags programmatically?

I tried just putting them in the text property and it just printed them out (the tags were printed as text).

3 Answers

try this:

textBlock1.FontWeight = Windows.UI.Text.FontWeights.Bold;

Related