Skip to content

Commit

Permalink
ViewHandler: Use the new flag to avoid setting tool tips unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
MartyIX committed Dec 10, 2024
1 parent dd94731 commit 2bb7162
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Core/src/Handlers/View/ViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,10 @@ public static void MapUnfocus(IViewHandler handler, IView view, object? args)
/// <param name="view">The associated <see cref="IView"/> instance.</param>
public static void MapToolTip(IViewHandler handler, IView view)
{
#if PLATFORM
#if WINDOWS
if (view is IToolTipElement tooltipContainer)
handler.ToPlatform().UpdateToolTip(tooltipContainer);
#elif PLATFORM
if (view is IToolTipElement tooltipContainer)
handler.ToPlatform().UpdateToolTip(tooltipContainer.ToolTip);
#endif
Expand Down
12 changes: 12 additions & 0 deletions src/Core/src/Platform/Windows/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,18 @@ public static async Task UpdateBackgroundImageSourceAsync(this FrameworkElement
await panel.UpdateBackgroundImageSourceAsync(imageSource, provider);
}

internal static void UpdateToolTip(this FrameworkElement platformView, IToolTipElement toolTipElement)
{
var content = toolTipElement.ToolTip?.Content;
var skipInitialization = (toolTipElement is IView view) && ((view.Handler as ElementHandler)?._isInitializing ?? false
|| content is not null);

if (!skipInitialization)
{
ToolTipService.SetToolTip(platformView, content);
}
}

public static void UpdateToolTip(this FrameworkElement platformView, ToolTip? tooltip)
{
ToolTipService.SetToolTip(platformView, tooltip?.Content);
Expand Down

0 comments on commit 2bb7162

Please sign in to comment.