简体   繁体   English

从“最大化”更改为“正常”时的窗口边框厚度

[英]Window border thickness when changing from Maximized to Normal

I have WPF application, which main window state I want to change from Maximized to Normal , while keeping actual size. 我有WPF应用程序,我希望将其主窗口状态从“ Maximized更改为“ Normal ,同时保持实际大小。 But there is one issue - for some reason (probably default behavior), after switching to Normal state, window always gets 1px border thickness. 但是有一个问题-由于某种原因(可能是默认行为),切换到“ Normal状态后,窗口的边框厚度始终为1px。 I can fix this by assigning BorderThickness property of window manually, right after setting WindowState to Normal , but it causes visible flickering. 我可以通过将WindowState设置为Normal之后立即手动分配window的BorderThickness属性来解决此问题,但这会导致可见的闪烁。 Moreover, if moving from Normal back to Maximized , and then back to Normal, window still gets border thickness, even if it was set to 0 before. 此外,如果从“普通”移回到“ Maximized ,然后又回到“普通”,则即使窗口之前被设置为0,窗口仍将获得边框粗细。

Is there any way to remove this default behavior for getting border thickness when switching to Normal ? 有什么方法可以删除此默认行为,以便在切换到“ Normal时获取边框粗细?

Make sure you directly update the BorderThickness propery inside a callback from changing the window state, like the StateChanged or SizeChanged events. 确保从更改窗口状态(如StateChanged或SizeChanged事件)的回调中直接更新BorderThickness属性。 This should remove the flickering. 这样可以消除闪烁。

Hint: You might confuse users with this behavior. 提示:您可能会使用户混淆这种行为。 Maybe it would be better not to allow maximizing in the first place. 也许最好一开始就不要最大化。 Or hide the window frame completelly. 或完全隐藏窗框。

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

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