Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Effects (DropShadowEffect) in Windows Phone 7

I noticed the Effect Property is missing in Silverlight for Windows Phone 7 so I did some googling and apperently it was dropped due to performance reasons. I basically want to do something like this

<TextBlock ...>
    <TextBlock.Effect>
        <DropShadowEffect/>
    </TextBlock.Effect>
</TextBlock>

And

<Image ...>
    <Image.Effect>
        <DropShadowEffect/>
    </Image.Effect>
</Image>

So is there some other way to get a DropShadowEffect in Silverlight for Windows Phone 7? And are there any news if it'll be in the next release?

Thanks

like image 273
Fredrik Hedblad Avatar asked Feb 16 '11 22:02

Fredrik Hedblad


2 Answers

With the image you can just simply create a drop shadow in Photoshop/Gimp etc (works well for me) and save it as .png.

With TextBlock it is a bit harder. For instance, create a half-transparent image with the shadow and place both TextBlock and the Image inside the Canvas. Change the Canvas.ZIndex="integer" attached property to place them in a specific order - image has to be underneath. Also shadow should be blurred.

The drawbacks are:

  • Shadow is static.
  • Doesn't really suit metro UX.
like image 165
Lukasz Madon Avatar answered Nov 05 '22 06:11

Lukasz Madon


<TextBlock ...>
 <TextBlock.RenderTransform>
  <TranslateTransform X="3" Y="3" />
 </TextBlock.RenderTransform>
</TextBlock>

<TextBlock ...>
</TextBlock>

I wanted a shadow effect and this worked for me. You need to put same content in both textblocks (except textblock name). X and Y are the horizonatal and vertical distance of shadow from text. You can also use negative numbers if depending on position of shadows.

like image 42
Tushar Jain Avatar answered Nov 05 '22 06:11

Tushar Jain