3

How do you apply stroke (outline around text) to a TextBlock in XAML in a Windows 8 store app (not WPF)?

A very similar question was asked in 2008, but the suggested solution from Apply stroke to a textblock in WPF and the referenced https://msdn.microsoft.com/en-us/library/ms745816.aspx only work on Windows Presentation Foundation (WPF) applications. The effect I am looking for is the same.

Thanks for your help!

Community
  • 1
  • 1
David
  • 2,019
  • 1
  • 23
  • 22
  • This looks trickier than I first thought due to the lack of `FormattedText` class in WinRT. Have found this http://pathtextblock.codeplex.com/SourceControl/latest but will need some refactoring, changing to custom control, testing etc – SWilko Mar 30 '15 at 11:20
  • 2
    If it's static text, then it's simple to just convert it to a `Path` and apply a stroke. Otherwise it gets a little more interesting. You could fake it with a DropShadow effect [see here](http://stackoverflow.com/questions/17835250/apply-stroke-to-textblock-in-xaml) otherwise it becomes a big pain of converting the text to path geometry dynamically. – Chris W. Mar 30 '15 at 13:14

1 Answers1

2

win2d text effects

I have successfully done it with Win2D effect http://expediteapps.com/blog/textblock-with-win2d-effects/

The idea is to apply two effects that create the outline effect. You can experiment with different ways and find the best combination you need. To add Win2D you can get it by nuget and is really easy to use.

and you do not need to convert the font to any strange glyphs.

Juan Pablo Garcia Coello
  • 3,192
  • 1
  • 23
  • 33