views:

116

answers:

3

I have a Label and want to add Shadow to it.

It seems like I can't apply the DropShadowBitmapEffect to it.

What else can I do?

+3  A: 

The bitmap effects are obsolete since .NET 3.5 (SP1?). Use DropShadowEffect instead.

EDIT: Since the effects are obsolete for a while, in .NET 4.0 they are an empty code block, i.e. do nothing.

Daniel Rose
+2  A: 

Use the DropShadowEffect instead of the DropShadowBitmapEffect. Bitmap-Effects are obsolete. But take care with effects. Use the WPF performance Suite to check the performance-behaviour of the used effects - I already have seen very bad performance impacts by using the effect-classes. See here for an example.

Another option would be to decorate the label with a Border. If you set the thickness accordingly, this would like a shadow:

<Border BorderThickness="1,1,20,20" BorderBrush="Black">
      <Label />
</Border>

(I have not looked how the above border looks like. You have to play around a bit to get a good result).

HCL
Thanks for the tip.I'm just using it with a single character-label, so I should be fine (could use an image instead as well).
Hedge
A: 

You can do this for Example:

<Label Content="LabelText:" >
       <Label.BitmapEffect>
             <DropShadowBitmapEffect Color="Black" Direction="320" ShadowDepth="10" Opacity=".5" Softness="9" />
        </Label.BitmapEffect>
</Label>
Tokk
Starting with .NET 4.0, this will do nothing. Use DropShadowEffect instead.
Daniel Rose
...and used in versions prior to 4.0, they will slow down the drawing of the UI (even if they are used very little and on small elements). I'm not 100% sure about it, but I have in mind that BitmapEffects force the rendering-engine to use software-rendering instead of hardware-rendering (if available).
HCL