Welcome to irritatedVowel.com Sign in | Help

POKE 53280,0: Pete Brown's Blog

Silverlight, WPF, Woodworking, .NET Programming, CNC, Nature, and other topics.

Pete Brown writes on a number of topics including Silverlight, WPF, .NET, woodworking and working as a consultant in the DC area. On most forums, Pete goes by the name Psychlist1972. Pete has worked at Applied Information Sciences (AIS) since 1996 where he currently performs as a lead architect and project manager.

Subscribe to my feed

Add to Technorati Favorites
Applied Information Sciences - My Employer



World Domination

who's online

Networks


View Pete Brown's profile on LinkedIn

AddThis Social Bookmark Button
Simulating Drop Shadows in Silverlight using Expression Design

Silverlight lacks the bitmap effects that are commonly used in WPF applications. Most can be simulated using pngs, but some can also be simulated using xaml. The example below shows a passable (but not perfect) drop shadow effect that relies only on vector content exported from Expression design.

First, open expression design and create a shape that duplicates the extents of the object you want the shadow behind. In this case, a simple rectangle with rounded corners.

pmb_drop_shadow_shadow_shape

Next, change the stroke to be one of the airbrush pens. You can also fiddle with the thickness to see what looks best to you. Something between 12 and 20 is typically plenty. The color used here will be the color of your drop shadow. Feel free to play around with some of the other strokes for other interesting or bizarre effects.

pmb_drop_shadow_stroke

You'll end up with a shape that looks like this:

pmb_drop_shadow_stroke_full

Note that I later changed the width to be 20 instead of the 13.33 seen in this screenshot.

Now, either unhide or add in the remainder of your UI elements and look to see if all is the way you want it. I like to also change the zoom to "actual pixels" when I'm checking my work.

pmb_drop_shadow_complete

Once you're good, export the xaml to Silverlight. The key here is to ensure that you vectorize the brush strokes. Play with the level of detail here until you get something that both looks good, and minimizes the amount of xaml generated. You can certainly go lower than the settings I chose for this example.

pmb_drop_shadow_export_dialog

The resulting xaml will contain a number of paths with varying opacities, simulating a drop-shadow that fades off to the edges.

pmb_drop_shadow_xaml

There are other approaches you could take, such as rasterizing live effects, but this example is a 100% vector approach and no additional asset downloads. You can also get clever with this approach and clipping regions to handle inner glows and other effects.

You can download all the source files from here. You can run it from here.

  Add to Technorati Favorites
Posted: Saturday, January 26, 2008 4:32 PM by Pete.Brown

Comments

Christopher Steen said:

MSBuild MSBuildContrib January Release [Via: Scott Dorman ] Sharepoint SharePoint Lists as DataTables...
# January 28, 2008 2:45 AM

Christopher Steen said:

Link Listing - January 27, 2008
# January 28, 2008 2:46 AM

Community Blogs said:

Pete Brown shows a way to add drop shadows to objects in Expression Design and staying 100% vector, and
# January 28, 2008 4:57 PM

Community Blogs said:

Guess it's late enough that I can't say it's Monday *somewhere*, huh? ... so 'Silverlight
# January 30, 2008 12:53 PM

POKE 53280,0: Pete Brown's Blog said:

A while back, I showed how to vectorize "drop shadows" in Expression Design. It wasn't perfect
# April 3, 2008 6:11 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Enter the text you see in the image:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS