Windows 8 C#/XAML - 在文本块文本周围创建边框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13196989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows 8 C#/XAML - Create a border around textblock text
提问by Slayter
I'm creating an app for the Windows 8 app store and I'm pretty new to the XAML UI stuff. What I want to do is create a black border around the actual text in the textblock. Any help would be greatly appreciated.
我正在为 Windows 8 应用程序商店创建一个应用程序,我对 XAML UI 的东西还很陌生。我想要做的是在文本块中的实际文本周围创建一个黑色边框。任何帮助将不胜感激。
Here is the textblock:
这是文本块:
<TextBlock Grid.Row="0" x:Name="TopLabel" VerticalAlignment="Top" Text="Top Label" HorizontalAlignment="Center" FontFamily="Impact" FontSize="48"/>
回答by Antonio Bakula
Use Border control :
使用边境控制:
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.border.aspx
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.border.aspx
something like this :
像这样:
<Border BorderBrush="Gray" BorderThickness="2" Grid.Row="0">
<TextBlock x:Name="TopLabel" VerticalAlignment="Top" Text="Top Label" HorizontalAlignment="Center" FontFamily="Impact" FontSize="48"/>
</Border>
回答by Jamie Keeling
I believe the term you are looking for is 'Stroke', other SO users have noticed that this affect appears to be absent from the shipped feature set.
我相信您正在寻找的术语是“中风”,其他 SO 用户已经注意到,随附的功能集中似乎没有这种影响。
The following question/solution should meet your needs - its based on WPF but both Windows 8 and WPF make use of XAML : Apply Stroke to Text
以下问题/解决方案应该可以满足您的需求——它基于 WPF,但 Windows 8 和 WPF 都使用 XAML:Apply Stroke to Text
Alternatively theres an informative MSDN article about it (again aimed at WPF but the principles should be the same) : How to: Create Outlined Text (MSDN)
或者,有一篇关于它的信息丰富的 MSDN 文章(同样针对 WPF,但原则应该是相同的):如何:创建轮廓文本 (MSDN)
I hope this helps!
我希望这有帮助!

