Creating a semi-transparent blurred background WPF

白昼怎懂夜的黑 提交于 2019-12-10 16:55:22

问题


I have a border, i want the background of this border to be partially transparent (opacity 0.8) but i do not want the image behind it to be well defined. The effect i am after is similar to the Windows Vista window border effect, where you can see that something is behind it but you cant tell what it is.

A few clarifications:
I am working on Windows XP, so i cant use Vista Glass
I need this solution to be portable across any windows platform

Any help would be appreciated :)


回答1:


Extend Glass Frame Into a WPF Application

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

DWM Blur Behind Overview

Hope one of those links helps. I used the 1'st link I had to add this class to make it work:

#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



回答2:


This is the best I could find on the net:

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

Considering the above is by a Microsoft guy, you'd be hard pressed to find a better way to do it.

It does a simple transparency on the window, so not quite like Aero glass. Aero effect is hardware accelerated and most certainly uses Direct3D in some way.

This SO answer talks about it in some detail:

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




回答3:


In Silverlight there is a Blur effect (http://www.silverlightshow.net/tips/Using-Blur-and-DropShadow-effects-in-Silverlight-3.aspx) should also be available for WPF (http://searchwindevelopment.techtarget.com/tip/0,289483,sid8_gci1377157,00.html) you can apply to controls. Maybe combining this with opacity would help you achive the desired goal?



来源:https://stackoverflow.com/questions/2786336/creating-a-semi-transparent-blurred-background-wpf

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