外发光效果到边框 [英] Outer glow effect to border

查看:214
本文介绍了外发光效果到边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为边框提供外发光效果?

How to provide the outer glow effect to border?

<Grid Width="200" Height="200">
    <Grid.Background>
        <RadialGradientBrush Center="0.5,0.5" GradientOrigin="0.5,0.5" RadiusX="0.8" RadiusY="0.8">
            <RadialGradientBrush.GradientStops>
                <GradientStop Offset="0" Color="#FF123B5F" />
                <GradientStop Offset="1" Color="#FF001F31" />
            </RadialGradientBrush.GradientStops>
        </RadialGradientBrush>
    </Grid.Background>
    <Border Width="180" Height="180" Margin="10" Background="Transparent"
            BorderBrush="White" BorderThickness="1">
        <Border.BitmapEffect>
            <OuterGlowBitmapEffect GlowColor="White" GlowSize="3" Opacity="1" />
        </Border.BitmapEffect>
    </Border>
</Grid>

我已经尝试过了,但是没有用

I have tried this but it not working

推荐答案

BitmapEffects.

来自 MSDN

重要在.NET Framework 4或更高版本中,BitmapEffect类为 过时的.如果您尝试使用BitmapEffect类,则将获得一个 过时的异常. BitmapEffect的非过时替代品 类是效果类.在大多数情况下,效果类为 明显更快.

Important In the .NET Framework 4 or later, the BitmapEffect class is obsolete. If you try to use the BitmapEffect class, you will get an obsolete exception. The non-obsolete alternative to the BitmapEffect class is the Effect class. In most situations, the Effect class is significantly faster.

这不是一回事,但是您可以尝试使用DropShadowEffect,将ShadowDepth设置为接近0.

It isn't the same thing but you can try with a DropShadowEffect with ShadowDepth close to 0 instead.

示例

<Border Width="180" Height="180" Margin="10" Background="Transparent"
        BorderBrush="White" BorderThickness="2" Opacity="1.0">
    <Border.Effect>
        <DropShadowEffect ShadowDepth="0"
                          Color="White"
                          Opacity="1"
                          BlurRadius="5"/>
    </Border.Effect>
</Border>

您所拥有的BitmapEffects与上面的DropShadowEffect之间的比较. DropShadowEffect在右侧.

Comparison between the BitmapEffects you had and DropShadowEffect above. DropShadowEffect to the right.

这篇关于外发光效果到边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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