user3422209
user3422209

Reputation: 195

How to define a textblock with a text and a binding with different font

I have created a TextBlock which contains both hardcode text and the binding text.

I want the binding text to be displayed in bold and hardcode text without bold.

<DataTemplate>
    <StackPanel Orientation="Vertical" HorizontalAlignment="Left">
        <TextBlock Text="{Binding Vendor,  StringFormat='Vendor: {0}'}" FontWeight="Medium"/>
        <TextBlock Text="{Binding Model,  StringFormat='Brand: {0}'}" FontWeight="Medium"/>
        <TextBlock Text="{Binding Description,  StringFormat='Description: {0}'}" FontWeight="Medium"/>
        <TextBlock Text="{Binding Material,  StringFormat='Material: {0}'}" FontWeight="Medium"/>
        <TextBlock Text="{Binding Color,  StringFormat='Color: {0}'}" FontWeight="Medium"/>
        <TextBlock Text="{Binding Size,  StringFormat='Size: {0}'}" FontWeight="Medium" Visibility="{Binding SizeVisible}"/>
        <TextBlock Text="{Binding Price,  StringFormat='Price: {0}'}" FontWeight="Medium"/>
    </StackPanel>
</DataTemplate>

Upvotes: 1

Views: 150

Answers (1)

ASh
ASh

Reputation: 35730

you can make two inline Run blocks:

<TextBlock>
    <Run Text="Vendor:"/>
    <Run Text="{Binding Vendor, Mode=OneWay}" FontWeight="Bold"/>
</TextBlock>

Upvotes: 2

Related Questions