scharette
scharette

Reputation: 10017

Applying multiple styles on Textblock populated by Data binding

I have a <TextBlock> element that look like this,

<TextBlock Text="{Binding Name, StringFormat= 'Name: {0}'}"/>

Now how would I go if I wanted to have the first part as Bold style and the second one as Italic style ,

eg.

Name: Person's name

At the moment using a style applies it on the result of my StringFormat.

Is there an easy way to accomplish this ?

Upvotes: 0

Views: 67

Answers (1)

Clemens
Clemens

Reputation: 128147

Use two Runs:

<TextBlock>
    <Run Text="Name:" FontWeight="Bold"/>
    <Run Text="{Binding Name}" FontStyle="Italic"/>
</TextBlock>

Upvotes: 3

Related Questions