WPF DropShadowEffect Causing Blurriness

独自空忆成欢 提交于 2019-12-18 15:05:19

问题


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


回答1:


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>



回答2:


There is a RendingQuality you can use to fix this issue. The default is biased for performance. Just do this:

<DropShadowEffect Color="#FFFD1E1E" ShadowDepth="0" RenderingBias="Quality"/>



回答3:


I'm not sure but try setting the BlurRadious for the Image.Effects to 0 by default it's 5 and see if it will help?

<Image.Effect>
    <DropShadowEffect BlurRadius="0"/>
</Image.Effect>


来源:https://stackoverflow.com/questions/1688384/wpf-dropshadoweffect-causing-blurriness

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!