Browse Source

Handle reparenting controls in SceneBuilder.

Attempt #2 after db8751d711 caused issue #3019.
pull/3030/head
Steven Kirk 6 years ago
parent
commit
c569f4b474
  1. 10
      src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs

10
src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs

@ -53,6 +53,16 @@ namespace Avalonia.Rendering.SceneGraph
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.

Loading…
Cancel
Save