【问题标题】:How can I still use the OuterGlowBitmapEffect in WPF4.0? Or if there is any user-made alternatives?如何在 WPF4.0 中仍然使用 OuterGlowBitmapEffect?或者是否有任何用户自制的替代品?
【发布时间】:2019-11-28 02:28:18
【问题描述】:

我需要在我的 TextBlock 中使用“外发光”效果,我看到了 OuterGlowBitmapEffect,但它在 WPF4.0 中不再起作用。 DropshadowEffect 和 BlurEffect 与 OuterGlowBitmapEffect 的工作方式不同。我想问一下是否有办法使用过时的 OuterGlowBitmapEffect 或者是否有任何用户制作的替代品,可以提供发光效果的库?

【问题讨论】:

标签: wpf effects effect bitmapeffect


【解决方案1】:

有时效果太亮,有办法让它更暗/更粗。

一种方法是应用两次效果,但由于您只能在控件上应用一次效果,因此您只需稍作工作即可。

     <Border>
        <Border.Effect>
            <DropShadowEffect Color="Black" ShadowDepth="0" BlurRadius="10" RenderingBias="Quality"></DropShadowEffect>
        </Border.Effect>
        <TextBlock Text="OuterGlowBitmapEffect" FontSize="28" Foreground="White">
            <TextBlock.Effect>
                <DropShadowEffect Color="Black" ShadowDepth="0" BlurRadius="10" RenderingBias="Quality"></DropShadowEffect>
            </TextBlock.Effect>
        </TextBlock>
    </Border>

在这种情况下,我使用边框在 TextBlock 上再次应用效果。 这会使 BlurRadius 变暗 2 倍。您也可以使用多种颜色,即 I.E.一种模糊效果可能更大一些(15?)和绿色,而主要的一种是黑色,以营造万圣节的感觉。

您也可以使用网格,然后将带有 DropShadowEffect 的 TextBlock 复制几次,直到获得您喜欢的黑暗。

    <Grid>
        <TextBlock Text="OuterGlowBitmapEffect" FontSize="28" Foreground="White">
            <TextBlock.Effect>
                <DropShadowEffect Color="Black" ShadowDepth="0" BlurRadius="10" RenderingBias="Quality"></DropShadowEffect>
            </TextBlock.Effect>
        </TextBlock>
        <TextBlock Text="OuterGlowBitmapEffect" FontSize="28" Foreground="White">
            <TextBlock.Effect>
                <DropShadowEffect Color="Black" ShadowDepth="0" BlurRadius="10" RenderingBias="Quality"></DropShadowEffect>
            </TextBlock.Effect>
        </TextBlock>
        <TextBlock Text="OuterGlowBitmapEffect" FontSize="28" Foreground="White">
            <TextBlock.Effect>
                <DropShadowEffect Color="Black" ShadowDepth="0" BlurRadius="10" RenderingBias="Quality"></DropShadowEffect>
            </TextBlock.Effect>
        </TextBlock>
        <TextBlock Text="OuterGlowBitmapEffect" FontSize="28" Foreground="White">
            <TextBlock.Effect>
                <DropShadowEffect Color="Black" ShadowDepth="0" BlurRadius="10" RenderingBias="Quality"></DropShadowEffect>
            </TextBlock.Effect>
        </TextBlock>
    </Grid>

【讨论】:

    猜你喜欢
    • 2015-04-04
    • 2021-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-25
    • 1970-01-01
    • 1970-01-01
    • 2011-01-31
    相关资源
    最近更新 更多