Window 左边位置失败

Window left position fail

这个问题对我来说既简单又意想不到。 我有一个 window

<Window x:Class="AppWorkFlowExecutor.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:AppWorkFlowExecutor"
            xmlns:fa="http://schemas.fontawesome.io/icons/"
            mc:Ignorable="d"
            Title="WF Executor" TextBlock.TextAlignment="Center" 
            FontFamily="Segoe UI" FontSize="14" PreviewMouseDown="Window_PreviewMouseDown"
            WindowStyle="None" AllowsTransparency="False" ResizeMode="CanResizeWithGrip" Margin="0"
            Closing="Window_Closing" KeyDown="Window_KeyDown" BorderThickness="1"  SizeChanged="Window_SizeChanged" >

我希望它从左上角开始。 但是结果是右边多了一点

图中蓝色是我的背景。所以我想我已经把它移到某个地方了。但是当我打印坐标时,我得到

这是正确的。 显然我对最高值没有问题

参见 MSDN:

Set the GlassFrameThickness property to specify the amount that the Windows Aero glass frame extends into the client area of a window. By default, the glass frame will use system values to emulate the look of a standard window. If Windows Aero is enabled, then the standard caption buttons (Maximize, Minimize, Close) are enabled and interactive. To make a custom window that does not have a glass frame, set this thickness to a uniform value of 0. This will disable the standard caption buttons.

请将玻璃框厚度设置为 0。我也已将 Left="0" Top="0" 添加到您的 XAML:

<Window x:Class="AppWorkFlowExecutor.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:AppWorkFlowExecutor"
            xmlns:fa="http://schemas.fontawesome.io/icons/"
            mc:Ignorable="d"
            Title="WF Executor" TextBlock.TextAlignment="Center" 
            FontFamily="Segoe UI" FontSize="14" PreviewMouseDown="Window_PreviewMouseDown"
            WindowStyle="None" AllowsTransparency="False" ResizeMode="CanResizeWithGrip" Margin="0" Left="0" Top="0"
            Closing="Window_Closing" KeyDown="Window_KeyDown" BorderThickness="1"  SizeChanged="Window_SizeChanged" >
<WindowChrome.WindowChrome>
    <WindowChrome GlassFrameThickness="0"></WindowChrome>
</WindowChrome.WindowChrome>