Repository navigation
Description
Current behavior 🐛
On Skia, a ToolTip whose content only fills itself in once it is in the visual tree shows an empty border the first time it opens. An ItemsControl is the common case: it only creates its item containers after it loads. The content stays empty for as long as that first open lasts. Closing and reopening the tooltip shows the content correctly, because by then the containers already exist when the tooltip is measured.
A ToolTip with plain string or other static content is not affected.
Root cause: ToolTip.AttachToPopup sets the tooltip's parent back to its previous value right after Popup.Child = this (to keep the owner's DataContext flowing in). UIElement.InvalidateParentMeasureDirtyPath walks that parent, so a measure invalidation raised inside the open tooltip marks the ToolTip and stops there. The PopupPanel is never marked, and no layout pass re-measures the tooltip. Dirty flags right after invalidating from inside an open tooltip:
content measureDirty=True measureDirtyPath=True
ToolTip measureDirty=False measureDirtyPath=True <- path stops here
panel measureDirty=False measureDirtyPath=False <- never marked
Calling InvalidateMeasure() on the content or the tooltip, or UpdateLayout(), doesn't help. Only PopupPanel.InvalidateMeasure() or re-setting Popup.Child makes the content appear.
Expected behavior 🎯
The tooltip is re-measured once its content has realized, and shows the items on its first open, as it does on WinUI and on every later open.
How to reproduce it (as minimally and precisely as possible) 🔬
dotnet new unoapp(Skia renderer), add aButton x:Name="MyButton"toMainPage.- In code-behind:
public MainPage()
{
this.InitializeComponent();
var items = new ItemsControl { ItemsSource = new[] { "first error", "second error" } };
ToolTipService.SetToolTip(MyButton, new ToolTip { Content = items });
}- Run on Desktop, hover the button.
- Observe: the tooltip shows only its border and padding. Move away and hover again: the two items now show.
Runtime test that reproduces it (fails on master):
[TestMethod]
public async Task When_Content_Realizes_On_Load_Then_Measured_On_First_Open()
{
var items = new ItemsControl { ItemsSource = new[] { "first error", "second error" } };
var SUT = new ToolTip { Content = items };
var owner = new Button { Content = "target" };
ToolTipService.SetToolTip(owner, SUT);
try
{
TestServices.WindowHelper.WindowContent = owner;
await TestServices.WindowHelper.WaitForLoaded(owner);
SUT.IsOpen = true;
await TestServices.WindowHelper.WaitFor(
() => items.ActualWidth > 0 && items.ActualHeight > 0,
timeoutMS: 3000,
message: "the tooltip's content was never measured on its first open");
}
finally
{
SUT.IsOpen = false;
VisualTreeHelper.CloseAllPopups(TestServices.WindowHelper.XamlRoot);
}
}Workaround 🛠️
After the tooltip opens and its content has loaded, call InvalidateMeasure() on the tooltip's Popup panel (internal), or set the popup's Child to null and back. Neither is reachable from app code, so there's no clean public workaround.
Renderer 🎨
- Skia
- Native
Affected platforms 📱💻🖥️
All platforms 🌍
Uno.Sdk version (and other relevant versions) 📦
master, and Uno.WinUI 7.0.0-dev.701 (net10.0-desktop).
IDE version 🧑💻
Not IDE related (dotnet CLI).
Anything else we need to know? 💬
We hit this with an error-message tooltip whose content is an ItemsControl bound to a list of messages. Same root cause as #24557 (an Image whose bitmap arrives after the tooltip opened); see comments below.
Activity
Xiaoy312 commentedon Sep 29, 2026
Related to #24557: same root cause, different trigger. There, an
Imageinside an open tooltip gets its bitmap after the tooltip opened; here, anItemsControlcreates its containers after the first measure. In both, the measure invalidation stops at theToolTipbecauseAttachToPopuprestores the tooltip's previous parent.@mikernet's PR #24592 (keep the
PopupPanelas parent while the tooltip is open) fixes this issue too. Checked on Skia desktop by applying the test above to the PR branch (eb38bcbb84):ToolTip.csWhen_Content_Realizes_On_Load_Then_Measured_On_First_Open(this issue)When_Image_Source_Loads_While_Open(#24557)It would be worth adding this test to #24592 so it covers the
ItemsControlcase as well.Xiaoy312 commentedon Sep 29, 2026
For reference, here is the fix we wrote for this issue before finding #24592.
It only fixes the
ItemsControlcase in this issue, not theImagecase in #24557. It forwards the tooltip's measure-dirty state to thePopupPanelfromLayoutUpdated, while the tooltip is open. That works here because theItemsControlinvalidates while the first-open layout pass is still running, soLayoutUpdatedis raised afterwards. A bitmap that arrives after layout has settled doesn't start a new pass, because the dirty path dead-ends at theToolTip. SoLayoutUpdatednever fires and the handler never runs. Measured on Skia desktop:ToolTip.csItemsControltest (this issue)Imagetest (#24557)#24592 repairs the parent chain itself, so it's the better fix. This is posted only as an alternative that leaves parenting and DataContext untouched. It covers measure only; an arrange invalidation inside an open tooltip is still lost.
ToolTip.csGiven_ToolTip.cs(test)test(tooltip): Cover content realizing inside an open ToolTip (fixes u…