diff --git a/samples/ControlCatalog/MainView.xaml.cs b/samples/ControlCatalog/MainView.xaml.cs
index 9c511f9eb0..5e33952c68 100644
--- a/samples/ControlCatalog/MainView.xaml.cs
+++ b/samples/ControlCatalog/MainView.xaml.cs
@@ -83,7 +83,7 @@ namespace ControlCatalog
if (transparencyLevels.SelectedItem is WindowTransparencyLevel selected)
{
var topLevel = (TopLevel)this.GetVisualRoot()!;
- topLevel.TransparencyLevelHint = selected;
+ topLevel.TransparencyLevelHint = new[] { selected };
if (selected != WindowTransparencyLevel.None)
{
diff --git a/samples/IntegrationTestApp/MainWindow.axaml.cs b/samples/IntegrationTestApp/MainWindow.axaml.cs
index 7130b3602a..689cfcb65d 100644
--- a/samples/IntegrationTestApp/MainWindow.axaml.cs
+++ b/samples/IntegrationTestApp/MainWindow.axaml.cs
@@ -136,7 +136,7 @@ namespace IntegrationTestApp
Name = "TransparentWindow",
SystemDecorations = SystemDecorations.None,
Background = Brushes.Transparent,
- TransparencyLevelHint = WindowTransparencyLevel.Transparent,
+ TransparencyLevelHint = new[] { WindowTransparencyLevel.Transparent },
WindowStartupLocation = WindowStartupLocation.CenterOwner,
Width = 200,
Height = 200,
diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs
index fae1aacf61..609b6cd519 100644
--- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs
+++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs
@@ -307,78 +307,80 @@ namespace Avalonia.Android.Platform.SkiaPlatform
bool isAboveR = Build.VERSION.SdkInt > BuildVersionCodes.R;
if (_view.Context is AvaloniaMainActivity activity)
{
- switch (transparencyLevel)
+ if (transparencyLevel == WindowTransparencyLevel.AcrylicBlur ||
+ transparencyLevel == WindowTransparencyLevel.Mica ||
+ transparencyLevel == WindowTransparencyLevel.None)
{
- case WindowTransparencyLevel.AcrylicBlur:
- case WindowTransparencyLevel.ForceAcrylicBlur:
- case WindowTransparencyLevel.Mica:
- case WindowTransparencyLevel.None:
- if (!isBelowR)
+ if (!isBelowR)
+ {
+ activity.SetTranslucent(false);
+ }
+ if (isAboveR)
+ {
+ activity.Window?.ClearFlags(WindowManagerFlags.BlurBehind);
+
+ var attr = activity.Window?.Attributes;
+ if (attr != null)
{
- activity.SetTranslucent(false);
- }
- if (isAboveR)
- {
- activity.Window?.ClearFlags(WindowManagerFlags.BlurBehind);
-
- var attr = activity.Window?.Attributes;
- if (attr != null)
- {
- attr.BlurBehindRadius = 0;
+ attr.BlurBehindRadius = 0;
- activity.Window.Attributes = attr;
- }
+ activity.Window.Attributes = attr;
}
- activity.Window.SetBackgroundDrawable(new ColorDrawable(Color.White));
+ }
+ activity.Window.SetBackgroundDrawable(new ColorDrawable(Color.White));
- if(transparencyLevel != WindowTransparencyLevel.None)
- {
- return;
- }
- break;
- case WindowTransparencyLevel.Transparent:
- if (!isBelowR)
- {
- activity.SetTranslucent(true);
- }
- if (isAboveR)
- {
- activity.Window?.ClearFlags(WindowManagerFlags.BlurBehind);
+ if (transparencyLevel != WindowTransparencyLevel.None)
+ {
+ return;
+ }
+ }
- var attr = activity.Window?.Attributes;
- if (attr != null)
- {
- attr.BlurBehindRadius = 0;
+ if (transparencyLevel == WindowTransparencyLevel.Transparent)
+ {
+ if (!isBelowR)
+ {
+ activity.SetTranslucent(true);
+ }
+ if (isAboveR)
+ {
+ activity.Window?.ClearFlags(WindowManagerFlags.BlurBehind);
+
+ var attr = activity.Window?.Attributes;
+ if (attr != null)
+ {
+ attr.BlurBehindRadius = 0;
- activity.Window.Attributes = attr;
- }
+ activity.Window.Attributes = attr;
}
- activity.Window.SetBackgroundDrawable(new ColorDrawable(Color.Transparent));
- break;
- case WindowTransparencyLevel.Blur:
- if (isAboveR)
- {
- activity.SetTranslucent(true);
- activity.Window?.AddFlags(WindowManagerFlags.BlurBehind);
+ }
+ activity.Window.SetBackgroundDrawable(new ColorDrawable(Color.Transparent));
+ }
- var attr = activity.Window?.Attributes;
- if (attr != null)
- {
- attr.BlurBehindRadius = 120;
+ if (transparencyLevel == WindowTransparencyLevel.Blur)
+ {
+ if (isAboveR)
+ {
+ activity.SetTranslucent(true);
+ activity.Window?.AddFlags(WindowManagerFlags.BlurBehind);
- activity.Window.Attributes = attr;
- }
- activity.Window.SetBackgroundDrawable(new ColorDrawable(Color.Transparent));
- }
- else
+ var attr = activity.Window?.Attributes;
+ if (attr != null)
{
- activity.Window?.ClearFlags(WindowManagerFlags.BlurBehind);
- activity.Window.SetBackgroundDrawable(new ColorDrawable(Color.White));
+ attr.BlurBehindRadius = 120;
- return;
+ activity.Window.Attributes = attr;
}
- break;
+ activity.Window.SetBackgroundDrawable(new ColorDrawable(Color.Transparent));
+ }
+ else
+ {
+ activity.Window?.ClearFlags(WindowManagerFlags.BlurBehind);
+ activity.Window.SetBackgroundDrawable(new ColorDrawable(Color.White));
+
+ return;
+ }
}
+
TransparencyLevel = transparencyLevel;
}
}
diff --git a/src/Avalonia.Controls/ExperimentalAcrylicBorder.cs b/src/Avalonia.Controls/ExperimentalAcrylicBorder.cs
index bc17fe7237..be1a90258c 100644
--- a/src/Avalonia.Controls/ExperimentalAcrylicBorder.cs
+++ b/src/Avalonia.Controls/ExperimentalAcrylicBorder.cs
@@ -56,22 +56,12 @@ namespace Avalonia.Controls
{
if (tl.PlatformImpl is null)
return;
-
- switch (x)
- {
- case WindowTransparencyLevel.Transparent:
- case WindowTransparencyLevel.None:
- Material.PlatformTransparencyCompensationLevel = tl.PlatformImpl.AcrylicCompensationLevels.TransparentLevel;
- break;
-
- case WindowTransparencyLevel.Blur:
- Material.PlatformTransparencyCompensationLevel = tl.PlatformImpl.AcrylicCompensationLevels.BlurLevel;
- break;
-
- case WindowTransparencyLevel.AcrylicBlur:
- Material.PlatformTransparencyCompensationLevel = tl.PlatformImpl.AcrylicCompensationLevels.AcrylicBlurLevel;
- break;
- }
+ if (x == WindowTransparencyLevel.Transparent || x == WindowTransparencyLevel.None)
+ Material.PlatformTransparencyCompensationLevel = tl.PlatformImpl.AcrylicCompensationLevels.TransparentLevel;
+ else if (x == WindowTransparencyLevel.Blur)
+ Material.PlatformTransparencyCompensationLevel = tl.PlatformImpl.AcrylicCompensationLevels.BlurLevel;
+ else if (x == WindowTransparencyLevel.AcrylicBlur)
+ Material.PlatformTransparencyCompensationLevel = tl.PlatformImpl.AcrylicCompensationLevels.AcrylicBlurLevel;
});
UpdateMaterialSubscription();
}
diff --git a/src/Avalonia.Controls/TopLevel.cs b/src/Avalonia.Controls/TopLevel.cs
index 98c96e4974..189dbe5e62 100644
--- a/src/Avalonia.Controls/TopLevel.cs
+++ b/src/Avalonia.Controls/TopLevel.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using Avalonia.Reactive;
@@ -22,6 +23,7 @@ using Avalonia.Utilities;
using Avalonia.Input.Platform;
using System.Linq;
using System.Threading.Tasks;
+using Avalonia.Metadata;
namespace Avalonia.Controls
{
@@ -64,8 +66,8 @@ namespace Avalonia.Controls
///
/// Defines the property.
///
- public static readonly StyledProperty TransparencyLevelHintProperty =
- AvaloniaProperty.Register(nameof(TransparencyLevelHint), WindowTransparencyLevel.None);
+ public static readonly StyledProperty> TransparencyLevelHintProperty =
+ AvaloniaProperty.Register>(nameof(TransparencyLevelHint), Array.Empty());
///
/// Defines the property.
@@ -172,7 +174,7 @@ namespace Avalonia.Controls
PlatformImpl = impl ?? throw new InvalidOperationException(
"Could not create window implementation: maybe no windowing subsystem was initialized?");
- _actualTransparencyLevel = PlatformImpl.TransparencyLevel;
+ _actualTransparencyLevel = PlatformImpl.TransparencyLevel;
dependencyResolver ??= AvaloniaLocator.Current;
@@ -310,8 +312,11 @@ namespace Avalonia.Controls
///
/// Gets or sets the that the TopLevel should use when possible.
+ /// Accepts multiple values which are applied in a fallback order.
+ /// For instance, with "Mica, Blur" Mica will be applied only on platforms where it is possible,
+ /// and Blur will be used on the rest of them. Default value is an empty array or "None".
///
- public WindowTransparencyLevel TransparencyLevelHint
+ public IReadOnlyList TransparencyLevelHint
{
get { return GetValue(TransparencyLevelHintProperty); }
set { SetValue(TransparencyLevelHintProperty, value); }
@@ -518,8 +523,8 @@ namespace Avalonia.Controls
{
if (PlatformImpl != null)
{
- PlatformImpl.SetTransparencyLevelHint(change.GetNewValue());
- HandleTransparencyLevelChanged(PlatformImpl.TransparencyLevel);
+ ////PlatformImpl.SetTransparencyLevelHint(
+ //// change.GetNewValue>() ?? Array.Empty());
}
}
else if (change.Property == ActualThemeVariantProperty)
@@ -610,27 +615,11 @@ namespace Avalonia.Controls
ScalingChanged?.Invoke(this, EventArgs.Empty);
}
- private static bool TransparencyLevelsMatch (WindowTransparencyLevel requested, WindowTransparencyLevel received)
- {
- if(requested == received)
- {
- return true;
- }
- else if(requested >= WindowTransparencyLevel.Blur && received >= WindowTransparencyLevel.Blur)
- {
- return true;
- }
-
- return false;
- }
-
private void HandleTransparencyLevelChanged(WindowTransparencyLevel transparencyLevel)
{
- if(_transparencyFallbackBorder != null)
+ if (_transparencyFallbackBorder != null)
{
- if(transparencyLevel == WindowTransparencyLevel.None ||
- TransparencyLevelHint == WindowTransparencyLevel.None ||
- !TransparencyLevelsMatch(TransparencyLevelHint, transparencyLevel))
+ if (transparencyLevel == WindowTransparencyLevel.None)
{
_transparencyFallbackBorder.Background = TransparencyBackgroundFallback;
}
@@ -660,7 +649,6 @@ namespace Avalonia.Controls
return;
_transparencyFallbackBorder = e.NameScope.Find("PART_TransparencyFallback");
-
HandleTransparencyLevelChanged(PlatformImpl.TransparencyLevel);
}
diff --git a/src/Avalonia.Controls/WindowTransparencyLevel.cs b/src/Avalonia.Controls/WindowTransparencyLevel.cs
index d463f74a0e..bce6e21e68 100644
--- a/src/Avalonia.Controls/WindowTransparencyLevel.cs
+++ b/src/Avalonia.Controls/WindowTransparencyLevel.cs
@@ -1,35 +1,51 @@
-namespace Avalonia.Controls
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace Avalonia.Controls;
+
+public readonly record struct WindowTransparencyLevel
{
- public enum WindowTransparencyLevel
+ private readonly string _value;
+
+ private WindowTransparencyLevel(string value)
{
- ///
- /// The window background is Black where nothing is drawn in the window.
- ///
- None,
-
- ///
- /// The window background is Transparent where nothing is drawn in the window.
- ///
- Transparent,
-
- ///
- /// The window background is a blur-behind where nothing is drawn in the window.
- ///
- Blur,
-
- ///
- /// The window background is a blur-behind with a high blur radius. This level may fallback to Blur.
- ///
- AcrylicBlur,
-
- ///
- /// Force acrylic on some incompatible versions of Windows 10.
- ///
- ForceAcrylicBlur,
-
- ///
- /// The window background is based on desktop wallpaper tint with a blur. This will only work on Windows 11
- ///
- Mica
+ _value = value;
+ }
+
+ ///
+ /// The window background is Black where nothing is drawn in the window.
+ ///
+ public static WindowTransparencyLevel None { get; } = new(nameof(None));
+
+ ///
+ /// The window background is Transparent where nothing is drawn in the window.
+ ///
+ public static WindowTransparencyLevel Transparent { get; } = new(nameof(Transparent));
+
+ ///
+ /// The window background is a blur-behind where nothing is drawn in the window.
+ ///
+ public static WindowTransparencyLevel Blur { get; } = new(nameof(Blur));
+
+ ///
+ /// The window background is a blur-behind with a high blur radius. This level may fallback to Blur.
+ ///
+ public static WindowTransparencyLevel AcrylicBlur { get; } = new(nameof(AcrylicBlur));
+
+ ///
+ /// The window background is based on desktop wallpaper tint with a blur. This will only work on Windows 11
+ ///
+ public static WindowTransparencyLevel Mica { get; } = new(nameof(Mica));
+
+ public override string ToString()
+ {
+ return _value;
}
}
+
+public class WindowTransparencyLevelCollection : ReadOnlyCollection
+{
+ public WindowTransparencyLevelCollection(IList list) : base(list)
+ {
+ }
+}
diff --git a/src/Avalonia.Native/WindowImplBase.cs b/src/Avalonia.Native/WindowImplBase.cs
index b802b1db71..c065346377 100644
--- a/src/Avalonia.Native/WindowImplBase.cs
+++ b/src/Avalonia.Native/WindowImplBase.cs
@@ -489,8 +489,12 @@ namespace Avalonia.Native
{
if (TransparencyLevel != transparencyLevel)
{
- if (transparencyLevel > WindowTransparencyLevel.Transparent)
+ if (transparencyLevel == WindowTransparencyLevel.Blur ||
+ transparencyLevel == WindowTransparencyLevel.AcrylicBlur ||
+ transparencyLevel == WindowTransparencyLevel.Mica)
+ {
transparencyLevel = WindowTransparencyLevel.AcrylicBlur;
+ }
TransparencyLevel = transparencyLevel;
diff --git a/src/Avalonia.X11/TransparencyHelper.cs b/src/Avalonia.X11/TransparencyHelper.cs
index 5ca2d1d337..b4f8ca5aed 100644
--- a/src/Avalonia.X11/TransparencyHelper.cs
+++ b/src/Avalonia.X11/TransparencyHelper.cs
@@ -41,7 +41,11 @@ namespace Avalonia.X11
private WindowTransparencyLevel UpdateAtomsAndGetTransparency()
{
- if (_requestedLevel >= WindowTransparencyLevel.Blur)
+ var blur = _requestedLevel == WindowTransparencyLevel.Blur ||
+ _requestedLevel == WindowTransparencyLevel.AcrylicBlur ||
+ _requestedLevel == WindowTransparencyLevel.Mica;
+
+ if (blur)
{
if (!_blurAtomsAreSet)
{
@@ -62,7 +66,7 @@ namespace Avalonia.X11
if (!_globals.IsCompositionEnabled)
return WindowTransparencyLevel.None;
- if (_requestedLevel >= WindowTransparencyLevel.Blur && CanBlur)
+ if (blur && CanBlur)
return WindowTransparencyLevel.Blur;
return WindowTransparencyLevel.Transparent;
}
diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguageParseIntrinsics.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguageParseIntrinsics.cs
index 819e721b36..df1c4aa6d6 100644
--- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguageParseIntrinsics.cs
+++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlLanguageParseIntrinsics.cs
@@ -274,6 +274,19 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions
}
}
+ if (type.Equals(types.WindowTransparencyLevel))
+ {
+ foreach (var property in types.WindowTransparencyLevel.Properties)
+ {
+ if (property.PropertyType == types.WindowTransparencyLevel && property.Name.Equals(text, StringComparison.OrdinalIgnoreCase))
+ {
+ result = new XamlStaticOrTargetedReturnMethodCallNode(node, property.Getter, Enumerable.Empty());
+
+ return true;
+ }
+ }
+ }
+
if (type.Equals(types.Uri))
{
var uriText = text.Trim();
@@ -385,7 +398,8 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions
result = new AvaloniaXamlIlArrayConstantAstNode(node, elementType.MakeArrayType(1), elementType, nodes);
return true;
}
- else if (type == context.Configuration.WellKnownTypes.IListOfT.MakeGenericType(elementType))
+ else if (type == context.Configuration.WellKnownTypes.IListOfT.MakeGenericType(elementType) ||
+ type == types.IReadOnlyListOfT.MakeGenericType(elementType))
{
var listType = context.Configuration.WellKnownTypes.IListOfT.MakeGenericType(elementType);
result = new AvaloniaXamlIlArrayConstantAstNode(node, listType, elementType, nodes);
diff --git a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs
index d160d4a277..05fe4bd2b8 100644
--- a/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs
+++ b/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs
@@ -117,6 +117,8 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers
public IXamlConstructor UriConstructor { get; }
public IXamlType Style { get; }
public IXamlType ControlTheme { get; }
+ public IXamlType WindowTransparencyLevel { get; }
+ public IXamlType IReadOnlyListOfT { get; }
public AvaloniaXamlIlWellKnownTypes(TransformerConfiguration cfg)
{
@@ -199,6 +201,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers
FontFamily = cfg.TypeSystem.GetType("Avalonia.Media.FontFamily");
FontFamilyConstructorUriName = FontFamily.GetConstructor(new List { Uri, XamlIlTypes.String });
ThemeVariant = cfg.TypeSystem.GetType("Avalonia.Styling.ThemeVariant");
+ WindowTransparencyLevel = cfg.TypeSystem.GetType("Avalonia.Controls.WindowTransparencyLevel");
(IXamlType, IXamlConstructor) GetNumericTypeInfo(string name, IXamlType componentType, int componentCount)
{
@@ -260,6 +263,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers
UriConstructor = Uri.GetConstructor(new List() { cfg.WellKnownTypes.String, UriKind });
Style = cfg.TypeSystem.GetType("Avalonia.Styling.Style");
ControlTheme = cfg.TypeSystem.GetType("Avalonia.Styling.ControlTheme");
+ IReadOnlyListOfT = cfg.TypeSystem.GetType("System.Collections.Generic.IReadOnlyList`1");
}
}
diff --git a/src/Windows/Avalonia.Win32/TrayIconImpl.cs b/src/Windows/Avalonia.Win32/TrayIconImpl.cs
index 5069add9fd..f2023d37ac 100644
--- a/src/Windows/Avalonia.Win32/TrayIconImpl.cs
+++ b/src/Windows/Avalonia.Win32/TrayIconImpl.cs
@@ -147,7 +147,7 @@ namespace Avalonia.Win32
SystemDecorations = SystemDecorations.None,
SizeToContent = SizeToContent.WidthAndHeight,
Background = null,
- TransparencyLevelHint = WindowTransparencyLevel.Transparent,
+ TransparencyLevelHint = new[] { WindowTransparencyLevel.Transparent },
Content = new TrayIconMenuFlyoutPresenter()
{
ItemsSource = menuItems
diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs
index 9217f42952..b8eb37bb33 100644
--- a/src/Windows/Avalonia.Win32/WindowImpl.cs
+++ b/src/Windows/Avalonia.Win32/WindowImpl.cs
@@ -435,7 +435,9 @@ namespace Avalonia.Win32
Marshal.FreeHGlobal(accentPtr);
- if (transparencyLevel >= WindowTransparencyLevel.Blur)
+ if (transparencyLevel == WindowTransparencyLevel.Blur ||
+ transparencyLevel == WindowTransparencyLevel.AcrylicBlur ||
+ transparencyLevel == WindowTransparencyLevel.Mica)
{
Win7EnableBlur(transparencyLevel);
}
@@ -447,13 +449,14 @@ namespace Avalonia.Win32
{
if (_isUsingComposition)
{
- var effect = transparencyLevel switch
- {
- WindowTransparencyLevel.Mica => BlurEffect.Mica,
- WindowTransparencyLevel.AcrylicBlur => BlurEffect.Acrylic,
- WindowTransparencyLevel.Blur => BlurEffect.Acrylic,
- _ => BlurEffect.None
- };
+ BlurEffect effect;
+
+ if (transparencyLevel == WindowTransparencyLevel.Mica)
+ effect = BlurEffect.Mica;
+ else if (transparencyLevel == WindowTransparencyLevel.AcrylicBlur)
+ effect = BlurEffect.Acrylic;
+ else
+ effect = BlurEffect.None;
if (Win32Platform.WindowsVersion >= WinUiCompositionShared.MinHostBackdropVersion)
{
@@ -485,27 +488,22 @@ namespace Avalonia.Win32
transparencyLevel = WindowTransparencyLevel.Blur;
}
- switch (transparencyLevel)
+ if (transparencyLevel == WindowTransparencyLevel.Transparent)
+ {
+ accent.AccentState = AccentState.ACCENT_ENABLE_TRANSPARENTGRADIENT;
+ }
+ else if (transparencyLevel == WindowTransparencyLevel.Blur)
+ {
+ accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND;
+ }
+ else if (transparencyLevel == WindowTransparencyLevel.AcrylicBlur || transparencyLevel == WindowTransparencyLevel.Mica)
+ {
+ accent.AccentState = AccentState.ACCENT_ENABLE_ACRYLIC;
+ transparencyLevel = WindowTransparencyLevel.AcrylicBlur;
+ }
+ else
{
- default:
- case WindowTransparencyLevel.None:
- accent.AccentState = AccentState.ACCENT_DISABLED;
- break;
-
- case WindowTransparencyLevel.Transparent:
- accent.AccentState = AccentState.ACCENT_ENABLE_TRANSPARENTGRADIENT;
- break;
-
- case WindowTransparencyLevel.Blur:
- accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND;
- break;
-
- case WindowTransparencyLevel.AcrylicBlur:
- case WindowTransparencyLevel.ForceAcrylicBlur: // hack-force acrylic.
- case WindowTransparencyLevel.Mica:
- accent.AccentState = AccentState.ACCENT_ENABLE_ACRYLIC;
- transparencyLevel = WindowTransparencyLevel.AcrylicBlur;
- break;
+ accent.AccentState = AccentState.ACCENT_DISABLED;
}
accent.AccentFlags = 2;
diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/WindowTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/WindowTests.cs
new file mode 100644
index 0000000000..a48776bfee
--- /dev/null
+++ b/tests/Avalonia.Markup.Xaml.UnitTests/Xaml/WindowTests.cs
@@ -0,0 +1,26 @@
+using Avalonia.Controls;
+using Avalonia.UnitTests;
+using Xunit;
+
+namespace Avalonia.Markup.Xaml.UnitTests.Xaml
+{
+ public class WindowTests : XamlTestBase
+ {
+ [Fact]
+ public void Can_Specify_TransparencyLevelHint()
+ {
+ using var app = UnitTestApplication.Start(TestServices.MockWindowingPlatform);
+ var xaml = @"";
+
+ var target = AvaloniaRuntimeXamlLoader.Parse(xaml);
+
+ Assert.Equal(
+ new[]
+ {
+ WindowTransparencyLevel.Blur,
+ WindowTransparencyLevel.Transparent,
+ WindowTransparencyLevel.None,
+ }, target.TransparencyLevelHint);
+ }
+ }
+}