Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a semi-transparent blurred background WPF

Tags:

wpf

xaml

blur

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 :)

like image 904
TerrorAustralis Avatar asked Oct 25 '22 15:10

TerrorAustralis


2 Answers

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
like image 179
Tono Nam Avatar answered Dec 01 '22 06:12

Tono Nam


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?

like image 40
Igor Zevaka Avatar answered Dec 01 '22 04:12

Igor Zevaka