White font with black border in XAML

2019-06-27 10:31发布

问题:

as the title says, I would like to have a black font with a white border in my TextBox.

How could it be achieved?

Cheers.

回答1:

Check out Blacklight controls @ http://blacklight.codeplex.com/. In particular look at the sample on http://mightymeaty.members.winisp.net/blacklight.silverlight/ | Visual Controls | TEXT | Stroke Text Block (Alpha).



回答2:

It's possible to convert text into geometry objects with advanced formatting like outlines and fills for individual letters - you can find out more about how to do that here.

Having said that, I'm not sure that this is possible inside a TextBox. It may be for read-only text (TextBlock) only.

Edit

This blog post shows some advanced font rendering techniques inside a TextBox. It may be handy for you.



回答3:

What I always do for that is set the font color to white and set a DropShadow effect on the text.

Next, play around with depth, angle (set to 0 or something) and blur and you should be able to get what you want.



回答4:

A full class and example using Geometries:

http://blogs.msdn.com/b/wpfsdk/archive/2006/12/24/using-text-as-a-decorative-graphic.aspx