Can you have a strikethrough text effect in UWP applications using TextBlock? Yes, with the TextDecorations property.

Posted: (EET/GMT+2)

 

If you've ever needed to display strikethrough text in a Universal Windows Platform (UWP) application, such as a new value next to an old one, you can do it easily using the TextDecorations property.

Here's a simple example in XAML:

<TextBlock Text="Was $99.00" TextDecorations="Strikethrough" />
<TextBlock Text="Now $59.00" Foreground="Green" Margin="8,0,0,0" />

The TextDecorations property accepts None, Underline, or Strikethrough as possible values. You can even combine them in code-behind:

myTextBlock.TextDecorations = TextDecorations.Underline | TextDecorations.Strikethrough;

That's all there is to it, you don't need any custom drawing logic or inline text runs. The decoration works just like in HTML or Word, and it adapts automatically to the application's theme and DPI settings.