diff --git a/src/Avalonia.Base/Visual.cs b/src/Avalonia.Base/Visual.cs index fbc940114a..8feba116f0 100644 --- a/src/Avalonia.Base/Visual.cs +++ b/src/Avalonia.Base/Visual.cs @@ -667,14 +667,8 @@ namespace Avalonia if (_visualParent is IRenderRoot || _visualParent?.IsAttachedToVisualTree == true) { - var root = this.FindAncestorOfType(); - if (root is null) - { - Logger.TryGet(LogEventLevel.Error, "Visual")?.Log("Visual", - "Visual is atached to visual tree but root could not be found."); - return; - } - + var root = this.FindAncestorOfType() ?? + throw new AvaloniaInternalException("Visual is atached to visual tree but root could not be found."); var e = new VisualTreeAttachmentEventArgs(_visualParent, root); OnAttachedToVisualTreeCore(e); }