{"record":{"id":"cd31f153feab8493","repo":"stride3d/stride","slug":"unable-to-reach-the-virtualizingtilepanel-of-the-associated","errorCode":null,"errorMessage":"Unable to reach the VirtualizingTilePanel of the associated ItemsControl.","messagePattern":"Unable to reach the VirtualizingTilePanel of the associated ItemsControl\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/View/Behaviors/TilePanelThumbnailPrioritizationBehavior.cs","lineNumber":60,"sourceCode":"            if (items == null || firstVisibleItemIndex > lastVisibleItemIndex)\n                return;\n\n            var session = items[0].Session;\n            var visibleAssets = items.Subset(firstVisibleItemIndex, lastVisibleItemIndex - firstVisibleItemIndex + 1).OfType<AssetViewModel>();\n            session.Thumbnails.IncreaseThumbnailPriority(visibleAssets);\n        }\n\n        private static VirtualizingTilePanel GetItemsPanel(DependencyObject itemsControl)\n        {\n            var itemsPresenter = itemsControl.FindVisualChildOfType<ItemsPresenter>();\n\n            if (itemsPresenter == null)\n                throw new InvalidOperationException(\"Unable to reach the ItemsPresenter of the associated ItemsControl.\");\n\n            var itemsPanel = (VirtualizingTilePanel)VisualTreeHelper.GetChild(itemsPresenter, 0);\n\n            if (itemsPanel == null)\n                throw new InvalidOperationException(\"Unable to reach the VirtualizingTilePanel of the associated ItemsControl.\");\n            return itemsPanel;\n        }\n    }\n}\n","sourceCodeStart":42,"sourceCodeEnd":65,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/View/Behaviors/TilePanelThumbnailPrioritizationBehavior.cs#L42-L65","documentation":"After locating the ItemsPresenter, GetItemsPanel expects its first visual child to be a VirtualizingTilePanel. If the child at index 0 is null (or not that panel type), the cast/check throws InvalidOperationException because thumbnail prioritization requires Stride's custom virtualizing panel.","triggerScenarios":"The ItemsControl's ItemsPanel is not (or does not wrap) a VirtualizingTilePanel — e.g. default VirtualizingStackPanel/WrapPanel, or VisualTreeHelper.GetChild(itemsPresenter, 0) returns null before panel realization.","commonSituations":"Using the behavior with a standard ItemsControl template whose panel is not VirtualizingTilePanel; panel realized later than the behavior's loaded hook.","solutions":["Set the ItemsPanel template to Stride's VirtualizingTilePanel: <ItemsPanelTemplate><vt:VirtualizingTilePanel/></ItemsPanelTemplate>","Wait for panel realization (generator status / Loaded) before calling GetItemsPanel","Search recursively among the presenter's children instead of assuming child index 0"],"exampleFix":"// before\n<ItemsControl.ItemsPanel>\n  <ItemsPanelTemplate><VirtualizingStackPanel/></ItemsPanelTemplate>\n</ItemsControl.ItemsPanel>\n// after\n<ItemsControl.ItemsPanel>\n  <ItemsPanelTemplate><stride:VirtualizingTilePanel/></ItemsPanelTemplate>\n</ItemsControl.ItemsPanel>","handlingStrategy":"validation","validationCode":"var presenter = itemsControl.FindVisualChildOfType<ItemsPresenter>();\nvar panel = presenter != null ? VisualTreeHelper.GetChild(presenter, 0) as VirtualizingTilePanel : null;\nif (panel == null) return; // wrong ItemsPanel or not realized","typeGuard":"static bool HasVirtualizingTilePanel(ItemsPresenter p) => p != null && VisualTreeHelper.GetChild(p, 0) is VirtualizingTilePanel;","tryCatchPattern":"try { var panel = GetItemsPanel(itemsControl); }\ncatch (InvalidOperationException) { log.Warn(\"ItemsPanel is not VirtualizingTilePanel\"); }","preventionTips":["Set ItemsPanelTemplate to VirtualizingTilePanel wherever this behavior is used","Cast with 'as' + null check instead of assuming child index 0 type","Keep the behavior and the panel template coupled in shared styles"],"tags":["wpf","visual-tree","items-panel"],"backgroundTag":"type-mismatch","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}