wpf 将笔触应用于 XAML 中的文本块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17835250/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 09:16:34  来源:igfitidea点击:

Apply stroke to textblock in XAML

c#wpfsilverlightxaml

提问by tnw

I have a Silverlightapp where I want to give my textblockan outline (notthe textblock, the charactersthemselves), otherwise known as stroke.

我有一个Silverlight应用程序,我想在其中给出我textblock的大纲(不是文本块,字符本身),也称为stroke.

I found this questionwhich works for WPF, but is there a way to accomplish this when working with XAML/Silverlight(PresentationFrameworkis not a Silverlightassembly)? Is there an existing implementation?

我发现这个问题适用于WPF,但是在使用XAML/Silverlight(PresentationFramework不是Silverlight程序集)时有没有办法做到这一点?是否有现有的实现?

回答by Tico

Going with @Chris W. idea, I came up with this code, although not the finest solution, it works:

与@Chris W. 想法一起,我想出了这个代码,虽然不是最好的解决方案,但它有效:

<StackPanel>

    <!-- With DropShadow -->
    <TextBlock Foreground="#FFFF0000" Text="With DropShadow" FontSize="16">
        <TextBlock.Effect>
            <DropShadowEffect ShadowDepth="0" BlurRadius="1" Color="#FF000000" />
        </TextBlock.Effect>
    </TextBlock>

     <!-- No DropShadow -->
    <TextBlock Foreground="#FFFF0000" Text="No DropShadow" FontSize="16" />

</StackPanel>