Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to re-size window in WPF when Allow Transparent is True

Tags:

c#

wpf

As you known, when allow transparent property is true, the border of window is hidden and we cannot re-size the window. We only re-size the window if we set ResizeMode is CanResizeWithGrip, but the solution is not good because we can re-size window when it's maximized and change by right corner of the window instead of all of 4 corners, so the question is how to how to re-size window in WPF when Allow Transparent is True without using CanResizeWithGrip?

Thanks in advance!

~Thi

like image 407
Thi Le Avatar asked Oct 15 '15 03:10

Thi Le


2 Answers

My expected is set window can re-size with hidden border, so finally I have found a solution to handle that, you can follow the below code:

<WindowChrome.WindowChrome>
    <WindowChrome     
        CaptionHeight="1"  
        CornerRadius ="0"
        ResizeBorderThickness="4"         
        GlassFrameThickness="0">
    </WindowChrome>
</WindowChrome.WindowChrome>

Please add more discussion if you want to know more information.

like image 187
Thi Le Avatar answered Oct 28 '22 21:10

Thi Le


Well, this is actually pretty easy. There is a property on the Window named ResizeMode, and if you set it to "CanResizeWithGrip", then a ResizeGrip control is placed on your window automatically, and if you run the app, it will, correctly, resize your window.

like image 28
Mohd Ahmed Avatar answered Oct 28 '22 22:10

Mohd Ahmed