简体   繁体   English

WPF删除窗口主体(仅标题栏)

[英]WPF Remove Window Body (Title Bar Only)

I'm trying to create a music player, and I wanted to have a "minimalist mode" where it collapses into a compact row of controls, much like WinAmp's docked mode . 我正在尝试创建一个音乐播放器,我想拥有一个“极简主义模式”,它可以折叠成紧凑的控件行,就像WinAmp的停靠模式一样

I was hoping to use MahApps.Metro to accomplish this, since it allows for controls in the title bar. 我希望使用MahApps.Metro来完成此操作,因为它允许标题栏中的控件。 However, WPF doesn't seem to allow a window body to be smaller than 8 px tall, so setting the window size to 28 (the height of the title bar) results in this weird 8-px-tall piece of the window body hanging off the bottom of the title bar once the window is moved. 但是,WPF似乎不允许窗口主体的高度小于8像素,因此将窗口大小设置为28(标题栏的高度)会导致这块奇怪的8像素高的窗口主体悬挂窗口移动后,将其移出标题栏底部

Also, setting WindowStyle to None isn't doable since that isn't supported by MahApps.Metro, which I would like to use when the window is in "normal mode". 另外,将WindowStyle设置为None也是不可行的,因为MahApps.Metro不支持该功能,我希望在窗口处于“正常模式”时使用它。

Is there any way to completely hide the body of a WPF window so that only the title bar is showing? 有什么方法可以完全隐藏WPF窗口的主体,以便仅显示标题栏?

I can totally reproduce your Issue with the Metro-Samples. 我可以使用Metro-Samples完全复制您的问题。

I did a Qick-fix to make it look like 我做了一个快速修复程序,使其看起来像 这个

Now it has no more pixels below the Titlebar. 现在,标题栏下方不再有像素。

What did i do? 我做了什么

To be honest it's more a workaround than a proper solution, but you can simply set TitlebarHeight="39" 坦白地说,这是解决问题的方法,而不是适当的解决方案,但是您只需设置TitlebarHeight="39"

Hope this fits your needs 希望这符合您的需求

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

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