创建半透明模糊背景WPF

时间:2010-05-07 05:04:43

标签: wpf xaml blur

我有一个边框,我希望这个边框的背景部分透明(不透明度为0.8),但我不希望它背后的图像被很好地定义。我所追求的效果类似于Windows Vista窗口边框效果,在那里你可以看到它背后的东西,但你不能告诉它是什么。

一些澄清:
我正在使用Windows XP,所以我不能使用Vista Glass
我需要这个解决方案可以在任何Windows平台上移植

任何帮助将不胜感激:)

3 个答案:

答案 0 :(得分:2)

Extend Glass Frame Into a WPF Application

WPF Window with aero glass background. (C# .NET)

DWM Blur Behind Overview

希望其中一个链接有所帮助。我使用了第一个链接,我必须添加这个类才能使它工作:

#region WINAPI Crap, none should handle this in 21st century
    private class NonClientRegionAPI
    {
        [StructLayout(LayoutKind.Sequential)]
        public struct MARGINS
        {
            public int cxLeftWidth;      // width of left border that retains its size
            public int cxRightWidth;     // width of right border that retains its size
            public int cyTopHeight;      // height of top border that retains its size
            public int cyBottomHeight;   // height of bottom border that retains its size
        };


        [DllImport("DwmApi.dll")]
        public static extern int DwmExtendFrameIntoClientArea(
            IntPtr hwnd,
            ref MARGINS pMarInset);

    }
    #endregion

答案 1 :(得分:1)

这是我在网上找到的最好的:

http://blogs.msdn.com/unnir/archive/2006/03/01/541154.aspx

考虑到上述内容是微软的一个人,你很难找到更好的方法。

它在窗户上做了一个简单的透明度,所以不太像Aero玻璃。 Aero效果是硬件加速的,并且肯定会以某种方式使用Direct3D。

这个SO答案详细讨论了它:

Is it possible to achieve the "Aero Glass" look on XP?

答案 2 :(得分:0)

在Silverlight中,还有一个模糊效果(http://www.silverlightshow.net/tips/Using-Blur-and-DropShadow-effects-in-Silverlight-3.aspx)也可用于WPF(http://searchwindevelopment.techtarget.com/tip/0,289483,sid8_gci1377157,00.html),您可以应用于控件。也许将它与不透明度结合起来可以帮助你达到预期目标吗?

相关问题