如何在 WindowStyle="None" AllowsTransparency=“False” 和 ResizeMode="CanResize" 时删除边框

How to remove border when WindowStyle="None" AllowsTransparency=“False” and ResizeMode="CanResize"

我有一个 window 具有以下属性

WindowState="Maximized"
WindowStyle="None, 
AllowsTransparency="False"
ResizeMode="CanResize"

但问题是 window 周围出现了边框。 如何在不更改任何这些属性的情况下修复它

当我将 AllowsTransparency 设置为 True 时,一些用户控件(例如 PdfViewer、WebBrowser 不显示内容。

 <Window x:Class="WpfApplication8.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStyle="None"
        WindowState="Maximized"
        AllowsTransparency="False"
        ResizeMode="CanResize"
        UseLayoutRounding="True"
        Title="MainWindow">
    <Grid Background="Red"></Grid>
</Window>

您可以使用 WindowChrome:

<Window x:Class="WpfApplication8.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStyle="None"
        AllowsTransparency="False"
        ResizeMode="CanResize"
        UseLayoutRounding="True"
        Title="MainWindow">
    <WindowChrome.WindowChrome>
        <WindowChrome CaptionHeight="0" ResizeBorderThickness="5" />
    </WindowChrome.WindowChrome>
    <Grid Background="Red"></Grid>
</Window>