将笔触应用于 XAML 中的文本块 [英] Apply stroke to textblock in XAML

查看:19
本文介绍了将笔触应用于 XAML 中的文本块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a Silverlight app where I want to give my textblock an outline (not the textblock, the characters themselves), otherwise known as stroke.

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

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

推荐答案

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

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

<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>

这篇关于将笔触应用于 XAML 中的文本块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆