From cbd89289ab2b49887ef4114ef0dfa0e52db701dd Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Tue, 19 May 2020 10:45:26 -0300 Subject: [PATCH] add TransparencyLevel property to TopLevel --- .../Platform/ITopLevelImpl.cs | 6 ++++++ src/Avalonia.Controls/TopLevel.cs | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Avalonia.Controls/Platform/ITopLevelImpl.cs b/src/Avalonia.Controls/Platform/ITopLevelImpl.cs index 98ee17ee1f..8e892ffc21 100644 --- a/src/Avalonia.Controls/Platform/ITopLevelImpl.cs +++ b/src/Avalonia.Controls/Platform/ITopLevelImpl.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Avalonia.Controls; using Avalonia.Input; using Avalonia.Input.Raw; using Avalonia.Rendering; @@ -106,5 +107,10 @@ namespace Avalonia.Platform IMouseDevice MouseDevice { get; } IPopupImpl CreatePopup(); + + /// + /// Gets or sets the ofthe TopLevel. + /// + WindowTransparencyLevel TransparencyLevel { get; set; } } } diff --git a/src/Avalonia.Controls/TopLevel.cs b/src/Avalonia.Controls/TopLevel.cs index d17f3b0423..8861c72418 100644 --- a/src/Avalonia.Controls/TopLevel.cs +++ b/src/Avalonia.Controls/TopLevel.cs @@ -43,6 +43,12 @@ namespace Avalonia.Controls public static readonly StyledProperty PointerOverElementProperty = AvaloniaProperty.Register(nameof(IInputRoot.PointerOverElement)); + /// + /// Represents the current . + /// + public static readonly StyledProperty TransparencyLevelProperty = + AvaloniaProperty.Register(nameof(TransparencyLevel), WindowTransparencyLevel.None); + private readonly IInputManager _inputManager; private readonly IAccessKeyHandler _accessKeyHandler; private readonly IKeyboardNavigationHandler _keyboardNavigationHandler; @@ -57,6 +63,9 @@ namespace Avalonia.Controls static TopLevel() { AffectsMeasure(ClientSizeProperty); + + TransparencyLevelProperty.Changed.AddClassHandler( + (tl, e) => { if (tl.PlatformImpl != null) tl.PlatformImpl.TransparencyLevel = (WindowTransparencyLevel)e.NewValue; }); } /// @@ -155,6 +164,15 @@ namespace Avalonia.Controls protected set { SetAndRaise(ClientSizeProperty, ref _clientSize, value); } } + /// + /// Gets or sets the . + /// + public WindowTransparencyLevel TransparencyLevel + { + get { return GetValue(TransparencyLevelProperty); } + set { SetValue(TransparencyLevelProperty, value); } + } + public ILayoutManager LayoutManager { get