Maximum custom window loses drop shadow effect

前端 未结 3 642
悲哀的现实
悲哀的现实 2020-12-28 08:24

I have a custom WPF window defined as:



        
3条回答
  •  醉梦人生
    2020-12-28 08:49

    So I found out a way to get this to work.

    You need to use the WPF Shell Integration Library (here) to do the work for you. As it's been written by MS, they have fixed (it seems) any issues with doing to the P/Invoke code.

    So it is easy to get a Window that has no Aero glass, is resizable on the edges, has a caption area that behaves with Aero snap, and has a drop shadow that reappears after min/maxing.

    This is the code for my window (note, you need to have referenced Microsoft.Windows.Shell)

    
    
        
            
        
    
        
    
        
    
    

    The is where you set all the different variables for the interop.

    • CaptionHeight: This is the height of the caption area (headerbar) that allows for the Aero snap, double clicking behaviour as a normal title bar does.
    • GlassFrameThickness: Setting this to 0,0,0,1 for some reason removes the chrome (glass), keeps the square border, and adds a drop shadow.
    • ResizeBorderThickness: This is thickness at the edge of the window which is where you can resize the window.

    Other things to note as that you keep the Window.WindowStyle property equal to SingleBorderWindow and let the Shell Library deal with removing the title, buttons and other chrome.

    So I kinda wasted my bounty there, but it looks like a completely viable solution that works a treat!

    EDIT:

    Here is a picture of the result: Sample Metro WPF Application

    I also put up a sample project on http://code.google.com/p/sample-metro-wpf-application/. It's an MIT license and people can use it however they want.

提交回复
热议问题