Skip to content

Commit

Permalink
Handle reparenting controls in SceneBuilder.
Browse files Browse the repository at this point in the history
Attempt #2 after db8751d caused issue #3019.
  • Loading branch information
grokys committed Sep 23, 2019
1 parent 25e0ed5 commit c569f4b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ public bool Update(Scene scene, IVisual visual)

if (visual.VisualRoot != null)
{
if (node?.Parent != null &&
visual.VisualParent != null &&
node.Parent.Visual != visual.VisualParent)
{
// The control has changed parents. Remove the node and recurse into the new parent node.
((VisualNode)node.Parent).RemoveChild(node);
Deindex(scene, node);
node = (VisualNode)scene.FindNode(visual.VisualParent);
}

if (visual.IsVisible)
{
// If the node isn't yet part of the scene, find the nearest ancestor that is.
Expand Down

0 comments on commit c569f4b

Please sign in to comment.