WPF DropShadowEffect Causing Blurriness

egoodberry picture egoodberry · Nov 6, 2009 · Viewed 7.6k times · Source

I've observed that applying a DropShadowEffect to a UIElement sporadically causes the UIElement's content to blur a bit. It's a pretty nasty effect: it can cause a photograph to look out of focus or worse- make an entire 'popup' region completely illegible.

I haven't seen anyone else complaining about this, so my inclination is to think that there is something that I am doing wrong.

Sample use (blurs content at random):

<Border>
   <Border.Effect>
      <DropShadowEffect />
   </Border.Effect>
   <!-- (Content) -->
</Border>

But removing the DropShadowEffect clears it up:

<Border>
    <!--<Border.Effect>
            <DropShadowEffect />
        </Border.Effect>-->
    <!-- (Content) -->
</Border>

Any ideas?

EDIT (added screenshot):

alt text http://signmgmt.com/eg/dropshadowblur.png

Answer

Jobi Joy picture Jobi Joy · Nov 6, 2009

What I do for this kind of scenarios is putting a Background Rectangle and apply the Blur effect just for that, so that the real content will be free from the effect, which in turn increases the performance. Because when you apply the effect to a visual all the subsequent children are also getting the effect applied, which makes the perf and looks gets bad. Try the below

 <Grid>
  <Rectangle ....>
  <Rectangle.Effect>
     <DropShadowEffect />
  </Rectangle.Effect>
 </Rectangle>
....Your content ...
</Grid>