2
votes

Is there a way to show text outline on a TextBlock? I am showing some text on top of map control and would like to show the text in black with white outline so it's always readable. Something like this:enter image description here

Thanks for any tips

1
There's no direct way to do this, you could convert it to a Geometry object which is easy if it's static text using Blend, or you could fake it with some imagination, but if it's static I can show you how pretty easy.Chris W.

1 Answers

1
votes

This sort of font manipulation isn't supported in Windows.UI.Xaml, but you can interop to DirectWrite to draw text with effects into a bitmap and then composite the bitmap on top of your map.

For static text you can either pre-create a bitmap or convert the font to paths as Chris W says. The Windows.UI.Xaml.Shapes.Path's Data is essentially the same as SVG's, so you can use many vector graphics programs for the converstion by saving to SVG and then copying the path data from SVG Path's d= attribute to Xaml Path's Data= attribute.

Drop shadows aren't supported in Windows.UI.Xaml without interop to Direct2D, so the fake it link won't give any advantage over DirectWrite in this environment.

The simplest way to ensure contrast would be to place the text on a partially transparent box, but that will give a different look.