From ab60beaa54623ec65abaf73f978871f346e2027e Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 18 May 2016 00:30:20 +0100 Subject: [PATCH] Check visual parent is not already set. When setting the visual parent of a control, make sure that it's not already set. The code in issue #513 was trying to reparent an already parented control, causing problems - this makes sure that this can't happen. --- src/Avalonia.SceneGraph/Visual.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Avalonia.SceneGraph/Visual.cs b/src/Avalonia.SceneGraph/Visual.cs index 6ae5d80677..6ecab23d6a 100644 --- a/src/Avalonia.SceneGraph/Visual.cs +++ b/src/Avalonia.SceneGraph/Visual.cs @@ -442,6 +442,11 @@ namespace Avalonia /// The visual parent. private void SetVisualParent(Visual value) { + if (value != null && _visualParent != null) + { + throw new InvalidOperationException("The control already has a visual parent."); + } + if (_visualParent == value) { return;