Hedge
Hedge

Reputation: 16748

WPF - How to add effects (like Shadow) to a Label

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?

Upvotes: 7

Views: 16516

Answers (3)

Daniel Rose
Daniel Rose

Reputation: 17638

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.

Upvotes: 5

HCL
HCL

Reputation: 36775

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).

Upvotes: 4

Tokk
Tokk

Reputation: 4502

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>

Upvotes: 8

Related Questions