Set TextBlock to be entirely bold when DataBound in WPF

48,244

Solution 1

Am I missing something, or do you just need to set the FontWeight property to "Bold"?

<TextBlock FontWeight="Bold" Text="{Binding Foo}" />

Solution 2

Rather than just having a TextBlock, try this:

<TextBlock>
  <Bold>
    <Run />
  </Bold>
</TextBlock>

Then databind to the Run.TextProperty instead.

Share:
48,244
danjarvis
Author by

danjarvis

I'm a PhD student at the Institute for Complex Systems Simulation at the University of Southampton, UK studying complexity in Remote Sensing. As part of my work I am heavily involved in Remote Sensing and GIS technologies - particularly ENVI/IDL programming and ArcGIS scripting using Python. My academic website shows some examples of my work, and links to some of the software I have written.

Updated on February 04, 2020

Comments

  • danjarvis
    danjarvis over 4 years

    I have a databound TextBlock control (which is being used inside a DataTemplate to display items in a ListBox) and I want to make all the text in the control bold. I can't seem to find a property in the properties explorer to set the whole text to bold, and all I can find online is the use of the <Bold> tag inside the TextBlock, but I can't put that in as the data is coming directly from the data source.

    There must be a way to do this - but how? I'm very inexperienced in WPF so I don't really know where to look.