{"record":{"id":"978a34591eeb3f58","repo":"AvaloniaUI/Avalonia","slug":"controls-for-pageslide-must-have-same-parent-978a34","errorCode":null,"errorMessage":"Controls for PageSlide must have same parent.","messagePattern":"Controls for PageSlide must have same parent\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Animation/PageSlide.cs","lineNumber":233,"sourceCode":"        /// Gets the common visual parent of the two control.\n        /// </summary>\n        /// <param name=\"from\">The from control.</param>\n        /// <param name=\"to\">The to control.</param>\n        /// <returns>The common parent.</returns>\n        /// <exception cref=\"ArgumentException\">\n        /// The two controls do not share a common parent.\n        /// </exception>\n        /// <remarks>\n        /// Any one of the parameters may be null, but not both.\n        /// </remarks>\n        protected static Visual GetVisualParent(Visual? from, Visual? to)\n        {\n            var p1 = (from ?? to)!.VisualParent;\n            var p2 = (to ?? from)!.VisualParent;\n\n            if (p1 != null && p2 != null && p1 != p2)\n            {\n                throw new ArgumentException(\"Controls for PageSlide must have same parent.\");\n            }\n\n            return p1 ?? throw new InvalidOperationException(\"Cannot determine visual parent.\");\n        }\n    }\n}\n","sourceCodeStart":215,"sourceCodeEnd":240,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Animation/PageSlide.cs#L215-L240","documentation":"Thrown by PageSlide.GetVisualParent when both 'from' and 'to' controls have non-null VisualParent values that differ. PageSlide animates two siblings sharing a common parent, so a mismatched parent makes the slide geometrically ambiguous.","triggerScenarios":"Calling a PageSlide transition between two controls that live in different panels/windows; one control reparented before the slide starts; animating controls from two different ContentControls.","commonSituations":"Swapping views in a ContentControl where the old content was already removed from the tree (parent becomes null on one side but the comparison still fails); using PageSlide on controls in separate TabControl tabs.","solutions":["Ensure both controls share the same immediate VisualParent before invoking the transition.","Pass null for the control that has already been detached (the method allows one null).","Use a different transition type (e.g. PageTurn) for cross-container animations."],"exampleFix":"// before\nslide.Start(from: controlA, to: controlB); // different parents\n\n// after\n// ensure both are children of the same panel first\npanel.Children.Add(controlB);\nslide.Start(from: controlA, to: controlB);","handlingStrategy":"validation","validationCode":"static bool ShareParent(Visual? a, Visual? b)\n{\n    var pa = (a ?? b)?.VisualParent;\n    var pb = (b ?? a)?.VisualParent;\n    return pa is null || pb is null || pa == pb;\n}","typeGuard":null,"tryCatchPattern":"if (!ShareParent(from, to)) throw new InvalidOperationException(\"Re-parent controls first\");\nslide.Start(from, to);","preventionTips":["Verify both controls share a parent before starting the slide.","Pass null for the already-detached control."],"tags":["animation","pageslide","visual-tree","argument"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}