Using a System.Drawing.Font with a WPF Label Using a System.Drawing.Font with a WPF Label wpf wpf

Using a System.Drawing.Font with a WPF Label


I would change it to a TextBlock control. The TextBlock control has the TextDecorations property you can use.

<TextBlock Name="textBlock" TextDecorations="Underline, Strikethrough" />

Or you can stick a TextBlock inside a Label if you really like (although I'd just use the TextBlock by itself).

<Label Name="label">    <TextBlock Name="textBlock" TextDecorations="Underline, Strikethrough" /></Label>

Have a look at the TextDecorations class.

I find that TextBlocks are more suitable than Labels in most situations. Here's a blog post about the differences. The chief difference being that a Label is a Control whereas a TextBlock is just a FrameworkElement. Also a Label supports access keys.


Looking at the code you already have, there might be a problem with it.On the MSDN on Windows Form and WPF Property mapping they make the comment:

Font size in WPF is expressed as one ninety-sixth of an inch, and in Windows Forms as one seventy-second of an inch. The corresponding conversion is:

Windows Forms font size = WPF font size * 72.0 / 96.0.