{"record":{"id":"db9772349662f21a","repo":"tui-cs/Terminal.Gui","slug":"computedlayout-for-superview-from-linked","errorCode":null,"errorMessage":"ComputedLayout for \"{superView}\": \"{from}\" linked with \"{to}\" was not found. Did you forget to add it to {superView}?","messagePattern":"ComputedLayout for \"(.+?)\": \"(.+?)\" linked with \"(.+?)\" was not found\\. Did you forget to add it to (.+?)\\?","errorType":"exception","errorClass":"LayoutException","httpStatus":null,"severity":"critical","filePath":"Terminal.Gui/ViewBase/View.Layout.cs","lineNumber":1256,"sourceCode":"                }\n\n                // if 'to' is not yet added to the result, add it\n                if (result.Find (v => v == to) is null)\n                {\n                    result.Add (to);\n                }\n\n                // remove from edge\n                edges.Remove ((from, to));\n            }\n            else if (from != superView?.GetTopSuperView (to, from) && !ReferenceEquals (from, to))\n            {\n                if (ReferenceEquals (from.SuperView, to))\n                {\n                    throw new LayoutException ($\"ComputedLayout for \\\"{superView}\\\": \\\"{to}\\\" \" + $\"references a SubView (\\\"{from}\\\").\");\n                }\n\n                throw new LayoutException ($\"ComputedLayout for \\\"{superView}\\\": \\\"{from}\\\" \"\n                                           + $\"linked with \\\"{to}\\\" was not found. Did you forget to add it to {superView}?\");\n            }\n        }\n\n        // return L (a topologically sorted order)\n        return result;\n    } // TopologicalSort\n\n    #endregion Topological Sort\n\n    #region Utilities\n\n    /// <summary>\n    ///     Gets the size of the SuperView's content (nominally the same as\n    ///     the SuperView's <see cref=\"GetContentSize ()\"/>) or the screen size if there's no SuperView.\n    /// </summary>\n    /// <remarks>\n    ///     This method provides fallback logic to ensure that a size is always returned, even if the SuperView is not set or","sourceCodeStart":1238,"sourceCodeEnd":1274,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/ViewBase/View.Layout.cs#L1238-L1274","documentation":"During the layout topological sort, a Pos/Dim referenced another view (e.g. Pos.Left(someView)) that is not present in the same SuperView hierarchy. The layout engine cannot position a view relative to one it does not know about, so it throws with a 'did you forget to add it' hint.","triggerScenarios":"view.X = Pos.Right(otherView) where otherView was never Add()ed to the same SuperView (or any SuperView); otherView was removed before layout; otherView belongs to a different container.","commonSituations":"Creating a view and setting relative positions before adding either view to a container; moving a view between containers but leaving stale Pos references; referencing a view from a different dialog/window.","solutions":["Add both views to the same SuperView before relying on relative Pos/Dim.","If a referenced view was removed, update the Pos to an Absolute or to the correct sibling.","Check the from/to names in the message to identify the missing view."],"exampleFix":"// before\nvar a = new View(); var b = new View();\na.X = Pos.Right(b); // b not in hierarchy\n// after\ncontainer.Add(a, b);\na.X = Pos.Right(b);","handlingStrategy":"validation","validationCode":"if (other.SuperView is null || !InternalSubViews.Contains(other))\n    Add(other); // or fix the reference\nview.X = Pos.Right(other);","typeGuard":"static bool AreInSameHierarchy (View a, View b) =>\n    a.SuperView is not null && a.SuperView == b.SuperView;","tryCatchPattern":null,"preventionTips":["Add both views to the same SuperView before using relative Pos.","Avoid stale references after Remove().","Use Absolute Pos if a referenced view may be absent."],"tags":["layout","topological-sort","hierarchy","pos"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}