Visual 'TextBlock' Is not a descendant of the specified ancestor 'RootVisual'
Posted: 19 Feb 2021, 00:11
Sometimes, when I try to show a popup I get the specified error above. I am creating a custom system of tooltips that are interactable.
I have an attachable property that listens to a MouseOver event. Once this happens, it calls a static method to create a popup and displays it. I add it to my top-level root Grid and it seems to work for the most part, but sometimes when I attach the property to an element that itself will be in a popup I get the error message.
I removed a lot of code. If the issue isn't obvious I can include more. I don't think this is a Noesis bug... I just don't understand what I'm doing wrong.
Video as well: https://files.catbox.moe/ijwks6.mp4
This error has also happened when I tried to add my attached property to a Run. I fixed that by passing the entire TextBlock instead of the run into Show(). Thank you for any insight you can give!
I have an attachable property that listens to a MouseOver event. Once this happens, it calls a static method to create a popup and displays it. I add it to my top-level root Grid and it seems to work for the most part, but sometimes when I attach the property to an element that itself will be in a popup I get the error message.
I removed a lot of code. If the issue isn't obvious I can include more. I don't think this is a Noesis bug... I just don't understand what I'm doing wrong.
Code: Select all
public static readonly DependencyProperty ToolTipContentProperty = DependencyProperty.RegisterAttached(
"ToolTipContent",
typeof(UIElement),
typeof(TTEx),
new PropertyMetadata(OnValueChanged));
private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
...
element.MouseEnter += (s, e) => TooltipManager.Show(d as FrameworkElement);
}
Code: Select all
public static async void Show(FrameworkElement element)
{
var popup = new Popup();
...
#if NOESIS
Navigation.Current.RootParent.ContentRoot.Children.Add(popup);
#endif
popup.IsOpen = true;
}
This error has also happened when I tried to add my attached property to a Run. I fixed that by passing the entire TextBlock instead of the run into Show(). Thank you for any insight you can give!