简体   繁体   中英

Resize borderless window wpf

我怎么能做到与WPF而不是Windows窗体?

You can do it by setting WindowChrome.

        /* Set Borderless Chrome to this Window */
        WindowChrome Resizable_BorderLess_Chrome = new WindowChrome();
        Resizable_BorderLess_Chrome.GlassFrameThickness = new Thickness(0);
        Resizable_BorderLess_Chrome.CornerRadius = new CornerRadius(0);
        Resizable_BorderLess_Chrome.CaptionHeight = 5.0;            
        WindowChrome.SetWindowChrome(this, Resizable_BorderLess_Chrome);

Add the above code inside the window constructor to obtain border less resizable window. Or you could use the window style setter to set the window chrome property:

<Setter Property="WindowChrome.WindowChrome">
        <Setter.Value>
            <WindowChrome CornerRadius="0" GlassFrameThickness="1" UseAeroCaptionButtons="False"/>
        </Setter.Value>
</Setter>

In addition to this you need to set ResizeMode to CanResize (or CanResizeWithGrip whatever that suits your purpose) and Window Style to None.

Refer MSDN link for more information

If you are looking for Metro UI like window please check this SO Question

Here is a sample in WPF. And another blog with a different sample.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM