WPF中标签的外发光效果和旋转 [英] Outer Glow Effect and rotation On A Label in WPF

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

问题描述

我需要在标签上创建外部发光效果并使其稍微旋转(大约 20 度).我正在使用以下代码,但它没有按照我想要的方式工作:

I need to create an outer glow effect on a label and make it rotate a little (by about 20 degrees). I'm using the following code, but it's not working the way I want it to:

<Label Height="106" Margin="80,57,36,0" Name="lblHeading" FontSize="35">
    Brian's 15th Birthday Party
    <Label.Effect>
        <DropShadowEffect BlurRadius="100" ShadowDepth="0" Opacity="1" 
                          Color="White"/>
    </Label.Effect>
</Label>

是否可以在窗口中的某处添加一些文本并为其添加外部发光效果和旋转?如果有人能帮我在标签上添加相同的效果或以任何其他方式在不使用标签控件的情况下添加相同的效果,那就太好了.

Is it possible to add some text somewhere in the Window and add an outer glow effect and rotation to it? It would be great if anyone can help me out with adding the same effect on a label or any other way to do so without using a label control.

我也尝试了以下方法,但没有帮助.也许我不知道如何使用它,因为它只是导致错误:

I tried the following, too, but it's not helping. Maybe I don't know how to use it because it's just causing an error:

<OuterGlowBitmapEffect GlowColor="Blue" GlowSize="30" Noise="1" Opacity="0.4" />

推荐答案

  1. 您可能希望使用较小的 BlurRadius,将其设置为 100 将使效果接近不可见.我建议 10 个.
  2. RenderTransformOrigin 设置为您希望文本围绕旋转的点(0.5, 0.5 表示围绕中心旋转).
  3. Label.RenderTransform 中添加一个 RotateTransform.
  1. You'll probably want to use a smaller BlurRadius, setting it to 100 will make the effect close to invisible. I suggest 10.
  2. Set the RenderTransformOrigin to the point you want the text to rotate around (0.5, 0.5 means rotate around the center).
  3. Add a RotateTransform inside Label.RenderTransform.

完整的代码应该类似于:

The complete code should look close to this:

<Label Height="106" Margin="80,57,36,0" Name="lblHeading" FontSize="35"
       RenderTransformOrigin="0.5, 0.5">
    Brian's 15th Birthday Party
    <Label.Effect>
        <DropShadowEffect BlurRadius="10" ShadowDepth="0" Opacity="1" 
                      Color="White"/>
    </Label.Effect>
    <Label.RenderTransform>
        <RotateTransform Angle="20"/>
    </Label.RenderTransform>
</Label>

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

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