From a4826b2036380299347bf7c42b56690ceb9ae997 Mon Sep 17 00:00:00 2001
From: Dong Bin <14807942+rabbitism@users.noreply.github.com>
Date: Thu, 23 Jul 2026 18:39:32 +0800
Subject: [PATCH] Add ToolTip.ShouldUseOverlayLayer attached property (#21830)
* feat: add ToolTip.ShouldUseOverlayLayer attached property
Add ShouldUseOverlayLayer attached property to ToolTip, which is bound
to Popup.ShouldUseOverlayLayer when the tooltip popup is created. This
allows per-control control over whether the tooltip popup uses the
overlay layer.
* docs: add proper XML docs for GetShouldUseOverlayLayer/SetShouldUseOverlayLayer
Replace pointing to Popup.ShouldUseOverlayLayer (a property)
with proper , , and documentation for the
getter and setter methods.
---
src/Avalonia.Controls/ToolTip.cs | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/Avalonia.Controls/ToolTip.cs b/src/Avalonia.Controls/ToolTip.cs
index 433098e3f5..7eeea5f0d4 100644
--- a/src/Avalonia.Controls/ToolTip.cs
+++ b/src/Avalonia.Controls/ToolTip.cs
@@ -81,6 +81,10 @@ namespace Avalonia.Controls
public static readonly AttachedProperty ServiceEnabledProperty =
AvaloniaProperty.RegisterAttached("ServiceEnabled", defaultValue: true, inherits: true);
+ ///
+ public static readonly AttachedProperty ShouldUseOverlayLayerProperty =
+ AvaloniaProperty.RegisterAttached("ShouldUseOverlayLayer");
+
///
/// Stores the current instance in the control.
///
@@ -301,6 +305,27 @@ namespace Avalonia.Controls
public static void SetServiceEnabled(Control element, bool value) =>
element.SetValue(ServiceEnabledProperty, value);
+ ///
+ /// Gets whether the tooltip popup for is shown in the overlay layer.
+ ///
+ /// The control to get the property from.
+ ///
+ /// See for details.
+ ///
+ public static bool GetShouldUseOverlayLayer(Control element) =>
+ element.GetValue(ShouldUseOverlayLayerProperty);
+
+ ///
+ /// Sets whether the tooltip popup for is shown in the overlay layer.
+ ///
+ /// The control to set the property on.
+ /// Whether to show the tooltip popup in the overlay layer.
+ ///
+ /// See for details.
+ ///
+ public static void SetShouldUseOverlayLayer(Control element, bool value) =>
+ element.SetValue(ShouldUseOverlayLayerProperty, value);
+
///
/// Adds a handler for the attached event.
///
@@ -421,7 +446,8 @@ namespace Avalonia.Controls
_popup.Bind(Popup.HorizontalOffsetProperty, control.GetBindingObservable(HorizontalOffsetProperty)),
_popup.Bind(Popup.VerticalOffsetProperty, control.GetBindingObservable(VerticalOffsetProperty)),
_popup.Bind(Popup.PlacementProperty, control.GetBindingObservable(PlacementProperty)),
- _popup.Bind(Popup.CustomPopupPlacementCallbackProperty, control.GetBindingObservable(CustomPopupPlacementCallbackProperty))
+ _popup.Bind(Popup.CustomPopupPlacementCallbackProperty, control.GetBindingObservable(CustomPopupPlacementCallbackProperty)),
+ _popup.Bind(Popup.ShouldUseOverlayLayerProperty, control.GetBindingObservable(ShouldUseOverlayLayerProperty))
});
_popup.PlacementTarget = control;