How to format text inline?

For example, if I have this:

string message = "The Quick Brown Fox";    
someTextBlock.Text = message;

it will be displayed by default as follows:

Quick brown fox

How to make it visible in a TextBlock (or any element with content)?

Like it: Fast Brown Fox

Note:

By "inline" I mean how this is done in HTML:

someDiv.InnerHtml = "The <b>Quick</b> Brown <b>Fox</b>";
+3
source share
1 answer

It is better to do this in XAML as follows:

<TextBlock>
    The <Bold>Quick</Bold> Brown <Bold>Fox</Bold> 
</TextBlock>

But you can also do this in code through a Inlinesproperty TextBlock:

someTextBlock.Inlines.Add(new Run() { Text = "The " });
someTextBlock.Inlines.Add(new Run() { Text = "Quick ",  FontWeight = FontWeights.Bold });
someTextBlock.Inlines.Add(new Run() { Text = "Brown " });
someTextBlock.Inlines.Add(new Run() { Text = "Fox",  FontWeight = FontWeights.Bold });
+4
source

All Articles