ChromedTitleBar forces Window shadows and borders to be visible

Themes, Shared, and Core Libraries for Avalonia UI Forum

Posted 2 months ago by John Smith
Avatar

I am trying to make window with rounded corners like windows has in Windows 11 (made big CornerRadius for example to see bug on both Windows 10 and Windows 11), but I have two problems. Added sample application source code to reproduce first bug - link.

1. ChromedTitleBar forces Window shadows and borders to be visible. In sample application first Window has ChromedTitleBar and it forces somehow shadows and borders of Window to be visible and I cant hide them. Second Window does not have ChromedTitleBar and it behaves as expected.

To see second Window in sample application change

desktop.MainWindow = new MainWindow();

to

desktop.MainWindow = new MainWindow2();

in App.axaml.cs

2. To make rounded corners I have to put DockPanel with ChromedTitleBar into two borders, but if any of this borders have backgroud then ChromedTitleBar becomes non-draggable.

<Border CornerRadius="50" BorderBrush="{actipro:ThemeResource Container2BorderBrush}" BorderThickness="2">
    <Border CornerRadius="49" ClipToBounds="True">

Could you add possibility to hide shadows and borders of window when using ChromedTitleBar or add possibility to set CornerRadius and border brush/thickness of window when using ChromedTitleBar?

[Modified 2 months ago]

Comments (3)

Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi John,

By default, ChromedTitleBar will configure the containing window for optimal use with native window chrome.  On Windows OS only, we set the following properties:

  • ExtendClientAreaChromeHints = NoChrome
  • ExtendClientAreaToDecorationsHint = True
  • ExtendClientAreaTitleBarHeight = (calculated final height of ChromedTitleBar)

If you set ExtendClientAreaToDecorationsHint = False the window chrome and borders will go away.  The side effect of doing this is that you will also lose the ability to reposition the window by dragging ChromedTitleBar.  Since ChromedTitleBar configures that property automatically, all you have to do is restore the value after it is set. In the code behind for the MainWindow, I added the following:

protected override void OnLoaded(RoutedEventArgs e) {
    base.OnLoaded(e);
    this.ExtendClientAreaToDecorationsHint = false;
}

With that in place, I was able to run your sample with ChromedTitleBar in place and no border/shadow for the window.


Actipro Software Support

Posted 1 month ago by John Smith
Avatar

So it can't be both with no border/shadow and been dragable?

Posted 1 month ago by Actipro Software Support - Cleveland, OH, USA
Avatar

That would be up to the Avalonia team.  ChromedTitleBar just works with the properties I mentioned and doesn't implement support for dragging a window or explicitly hiding/showing the border/shadow.  That's all handled by the Avalonia window and we just make sure that ChromedTitleBar doesn't block the mouse clicks from being handled by the window.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.