Search code examples
c#wpfxamlwindow

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


I have a window with the following properties

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

But the problem is a border appears around the window. How can I fix it without changing any of these properties

When I set AllowsTransparency True some user controls such as PdfViewer,WebBrowser not displaying contents.

 <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>

Solution

  • You could use a 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>