简体   繁体   English

如何使用 WPF 实现无边框窗口?

[英]How do I implement a chromeless window with WPF?

I want to show a chromeless modal window with a close button in the upper right corner.我想在右上角显示一个带有关闭按钮的无边框模式窗口。 Is this possible?这可能吗?

You'll pretty much have to roll your own Close button, but you can hide the window chrome completely using the WindowStyle attribute, like this:您几乎必须滚动自己的关闭按钮,但您可以使用 WindowStyle 属性完全隐藏窗口镶边,如下所示:

<Window WindowStyle="None">

That will still have a resize border.那仍然会有一个调整大小的边框。 If you want to make the window non-resizable then add ResizeMode="NoResize" to the declaration.如果要使窗口不可调整大小,请在声明中添加 ResizeMode="NoResize"。

The WPF SDK Team posted a EXCELLENT article about chromeless windows available here: http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx WPF SDK团队在此发布了一篇关于无格式窗口的优秀文章: http//blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx

This is a MUST read!!! 这是必须读的!!!

UPDATED 更新

替代文字

Also found this article by Lester Lebo on how to use the WPF Shell Integration Library for a custom window chrome 同时还发现文章由莱斯特·莱博如何使用WPF外壳集成库自定义窗口镶边

Check out this blog post on kirupa .查看关于kirupa 的这篇博

替代文字

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300" WindowStyle="None" ResizeMode="NoResize">
    <Button HorizontalAlignment="Right" Name="button1" VerticalAlignment="Top" >Close</Button>
</Window>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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