Repository: unoplatform/uno
File: src/Uno.UI/UI/Xaml/Controls/ToolTip/ToolTipService.cs (C#)

Code before:

			CloseToolTipImpl(toolTip);
		});
	}

	private static void OnOwnerVisibilityChanged(DependencyObject sender, DependencyProperty dp)
	{
		if (sender is FrameworkElement owner && owner.Visibility != Visibility.Visible)
		{
			if (GetToolTipReference(owner) is { } toolTip)
			{
				CloseToolTipImpl(toolTip);
			}
		}
	}

	private static void OnOwnerLoaded(object sender, RoutedEventArgs e)
	{
		if (sender is FrameworkElement owner && GetActualToolTipObject(owner) is { } toolTip)
		{
			owner.PointerEntered += OnPointerEntered;
			owner.GotFocus += OnGotFocus;
			owner.PointerExited += OnPointerExitedOrCanceledOrCaptureLostOrLostFocus;
			owner.PointerCaptureLost += OnPointerExitedOrCanceledOrCaptureLostOrLostFocus;
			owner.PointerCanceled += OnPointerExitedOrCanceledOrCaptureLostOrLostFocus;
			owner.LostFocus += OnPointerExitedOrCanceledOrCaptureLostOrLostFocus;
			owner.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(OnKeyDown), true);
			if (owner is ButtonBase)
			{
				owner.AddHandler(UIElement.PointerPressedEvent, new PointerEventHandler(OnPointerPressed), true);
			}
			var token = owner.RegisterPropertyChangedCallback(UIElement.VisibilityProperty, OnOwnerVisibilityChanged);
			toolTip.OwnerVisibilitySubscription = Disposable.Create(() =>
			{
				owner.UnregisterPropertyChangedCallback(UIElement.VisibilityProperty, token);
			});
		}
	}

	private static void OnGotFocus(object sender, RoutedEventArgs e)
	{
		if (sender is FrameworkElement owner && GetActualToolTipObject(owner) is { } toolTip)
		{
			if (toolTip.IsOpen) return;

			if (m_OpenTimer is null)
			{
				m_OpenTimer = new DispatcherTimer();
				m_OpenTimer.Interval = TimeSpan.FromMilliseconds(FeatureConfiguration.ToolTip.ShowDelay);
				m_OpenTimer.Tick += OnOpenTimerTick;
			}

Review comment (suggestion):
I suspect we should subscribe to `handledEventsToo`.

Code after:
			OnOwnerLoaded(control, null);
		}
		control.Loaded += OnOwnerLoaded;
		control.Unloaded += OnOwnerUnloaded;

		return Disposable.Create(() =>
		{
			control.Loaded -= OnOwnerLoaded;
			control.Unloaded -= OnOwnerUnloaded;
			OnOwnerUnloaded(control, null);

			CloseToolTipImpl(toolTip);
		});
	}

	private static void OnOwnerVisibilityChanged(DependencyObject sender, DependencyProperty dp)
	{
		if (sender is FrameworkElement owner && owner.Visibility != Visibility.Visible)
		{
			if (GetToolTipReference(owner) is { } toolTip)
			{
				CloseToolTipImpl(toolTip);
			}
		}
	}

	private static void OnOwnerLoaded(object sender, RoutedEventArgs e)
	{
		if (sender is FrameworkElement owner && GetActualToolTipObject(owner) is { } toolTip)
		{
			owner.PointerEntered += OnPointerEntered;
			owner.GotFocus += OnGotFocus;
			owner.PointerExited += OnPointerOutOrLostFocus;
			owner.PointerCaptureLost += OnPointerOutOrLostFocus;
			owner.PointerCanceled += OnPointerOutOrLostFocus;
			owner.LostFocus += OnPointerOutOrLostFocus;
			owner.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(OnKeyDown), true);
			if (owner is ButtonBase)
			{
				owner.AddHandler(UIElement.PointerPressedEvent, new PointerEventHandler(OnPointerPressed), true);
			}
			var token = owner.RegisterPropertyChangedCallback(UIElement.VisibilityProperty, OnOwnerVisibilityChanged);
			toolTip.OwnerVisibilitySubscription = Disposable.Create(() =>
			{
				owner.UnregisterPropertyChangedCallback(UIElement.VisibilityProperty, token);
			});
		}
	}

	private static void OnOwnerUnloaded(object sender, RoutedEventArgs e)
	{