如何使用WindowStyle = None删除WPF窗口顶部的白色条带? [英] How to remove white strip on top of WPF window with WindowStyle=None?
问题描述
是否可以使用 Window Style=None 删除 WPF 窗口顶部的白色条带.XAML 和窗口显示在屏幕截图中:
Is it possible to remove the white strip on top of WPF window with Window Style=None. XAML and Window is shown in the screenshot:
推荐答案
您看到的白色是重新调整边框大小.您可以通过设置 ResizeMode="CanResizeWithGrip" AllowsTransparency="True"
What you are seeing in white is the re-size border. You can remove that and still make the window resizable by setting ResizeMode="CanResizeWithGrip" AllowsTransparency="True"
如果您根本不想调整大小,请执行此操作 - ResizeMode="NoResize"
,同样您将看不到边框但无法调整大小.
If you dont want to resize at all then do this - ResizeMode="NoResize"
, again you wont see the border but you cant resize.
<Window x:Class="HandsOnSolution.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Background="Green" WindowStyle="None" ResizeMode="CanResizeWithGrip" AllowsTransparency="True">
<Grid>
</Grid>
</Window>
编辑
@devuxer 的好点子,如果您对拖动感兴趣,可以将这段代码添加到窗口鼠标按下事件中
Good point by @devuxer, if you are interested in dragging you can add this piece of code to the window mouse down event
<Window MouseLeftButtonDown="Window_MouseLeftButtonDown"/>
//code behind
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
这篇关于如何使用WindowStyle = None删除WPF窗口顶部的白色条带?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!