Search code examples
wpfxamldata-bindingmultibinding

Styling the MultiBinding TextBlock in WPF


I'm trying to Bold only one of the TextBlocks in multibinding.

The Multibinding code is,

<TextBlock  TextWrapping="Wrap" Padding="2 0 0 0">
    <TextBlock.Text>
        <MultiBinding StringFormat="{}{0}{1}">
            <Binding Path="Value" Mode="OneWay"/>
            <Binding Path="Status" Mode="OneWay" />
        </MultiBinding>
    </TextBlock.Text>
</TextBlock>

In the above block, I want to bold the second binding alone. Something like this

<Binding Path="Status" Mode="OneWay" FontWeight="Bold"/>

But there is no FontWeight property for the Binding Control.

Is there any other property to add style to the Binding tag? or Is there any other way that I can add style only to a particular TextBlock in MultiBinding?


Solution

  • Binding isn't a control and can not have a Style

    for TextBlock you can declare Inlines

    <TextBlock TextWrapping="Wrap" Padding="2 0 0 0">
        <Run Text="{Binding Value, Mode=OneWay}"/>
        <Run Text="{Binding Status, Mode=OneWay}" FontWeight="Bold"/>
    </TextBlock>