Silverlight Tip – How to make bold text in a textblock from the CodeBehind

by Steve French in How To Fix, Silverlight on July 27, 2010

The Problem: You need to conditionally bold text in a text block, but you cannot find any way of doing so

The Cause: For inexplicable reasons, Microsoft chose not to include a FontWeight.Bold in their xaml specification

The Solution: Microsoft did include a FontWeights (note the S) class  To bold text in the codebehind, all you have to do is write this

tbbDownloader.FontWeight = FontWeights.Bold;

And presto!  Bold Text.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog