问题
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:
Thanks for any tips
回答1:
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.
来源:https://stackoverflow.com/questions/26681319/windows-phone-8-1-runtime-text-outline