AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.55k stars 2.21k forks source link

SystemDecorations.BorderOnly has an artifact in the version 11.0.2 #12503

Closed UralMichael closed 2 months ago

UralMichael commented 1 year ago

Describe the bug I have an application where the main window is configured to not have the default window bar (SystemDecorations="BorderOnly").

I updated Avalonia packages to the new version 11.0.2.

Now the window has an artifact margin on the top side.

To Reproduce

  1. Create project from the default template Avalonia .NET App (Avalonia UI)
  2. Update Avalonia and Avalonia.Desktop packages to the version 11.0.2
  3. Set SystemDecorations="BorderOnly" in the main window
  4. Build and start the app

MainWindow.axaml:

<Window xmlns="https://github.com/avaloniaui"
        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"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="AvaloniaApplication1.MainWindow"
        SystemDecorations="BorderOnly"
        Title="AvaloniaApplication1">
    Welcome to Avalonia!
</Window>

Project file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Avalonia" Version="11.0.2" />
    <PackageReference Include="Avalonia.Desktop" Version="11.0.2" />
    <PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0" />
    <PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.0" />
    <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
    <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0" />
  </ItemGroup>
</Project>

Screenshots

11.0.0:

11_0_0

11.0.2:

11_0_2

Desktop:

timunie commented 1 year ago

why not updating all packages?

UralMichael commented 1 year ago

@timunie Initially I updated everything to 11.0.2 in my project. In the template I wanted to find the exact package that causes the artifact.

I've just re-checked the template project with updating everything to 11.0.2 and even to 11.0.3. The result is the same.

kekekeks commented 1 year ago

@emmauss could you check if we have some window styles that shouldn't be there in borderless mode?

baochenw commented 2 months ago

Set ExtendClientAreaTitleBarHeightHint="0" to workaround it.

SCLDGit commented 2 months ago

Can confirm that this is still an issue in 11.1.3. BorderOnly has a small sliver of title bar visible on Windows 11. Additionally, BorderOnly seemingly causes window to not respect CanResize="False"

emmauss commented 2 months ago

Forgot to post an explanation here. On Windows, BorderOnly will for the OS to apply a border on the window. On Windows 10 and newer, that border is invisible on the left, bottom and right of the window, but visible on the top. That's the white line you see in the pics. Its not an artifact, it the OS applied border. This behavior can not be removed for BorderOnly. As for setting CanResize being ignored, this should be fixed in master. Due to the behaviors of BorderOnly and CanResize=False being mutually exclusive, CanResize=false essentially removes BorderOnly is enabled, because setting a window Border makes a window resizable