Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outer Glow Effect and rotation On A Label in WPF

Tags:

c#

wpf

xaml

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" />
like image 224
Ali Rizwan Avatar asked Jul 15 '12 16:07

Ali Rizwan


2 Answers

  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>
like image 155
Adam Avatar answered Nov 16 '22 20:11

Adam


This is how you can rotate your label:

<Label>
  <Label.LayoutTransform>
    <RotateTransform Angle="20"/>
  </Label.LayoutTransform>
  <Label.Content>text</Label.Content>
</Label>
like image 29
Surfbutler Avatar answered Nov 16 '22 20:11

Surfbutler