WPF DropShadowEffect导致模糊 [英] WPF DropShadowEffect Causing Blurriness

查看:341
本文介绍了WPF DropShadowEffect导致模糊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我观察到,将DropShadowEffect偶尔应用于UIElement会导致UIElement的内容模糊一些.这是一个非常令人讨厌的效果:它可能导致照片看起来模糊不清,甚至变得更糟-使整个弹出"区域完全难以辨认.

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>

但是删除DropShadowEffect可以清除它:

But removing the DropShadowEffect clears it up:

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

有什么想法吗?

编辑(添加了屏幕截图):

EDIT (added screenshot):

替代文字http://signmgmt.com/eg/dropshadowblur.png

推荐答案

在这种情况下,我要做的是放置一个背景矩形"并为此应用模糊"效果,以使实际内容不受该效果影响,从而提高了性能.因为当您将效果应用于视觉效果时,所有后续子级也会获得效果的应用,这会使性能和外观变差.试试下面的

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>

这篇关于WPF DropShadowEffect导致模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆