{"record":{"id":"b146989d0e7997c9","repo":"stride3d/stride","slug":"a-part-named-part-listbox-must-be-present-in-the","errorCode":null,"errorMessage":"A part named 'PART_ListBox' must be present in the ControlTemplate, and must be of type 'ListBox'.","messagePattern":"A part named 'PART_ListBox' must be present in the ControlTemplate, and must be of type 'ListBox'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/Controls/FilteringComboBox.cs","lineNumber":244,"sourceCode":"        {\n            var filteringComboBox = (FilteringComboBox)d;\n            if (filteringComboBox.ItemsSource != null)\n            {\n                filteringComboBox.UpdateCollectionView();\n            }\n        }\n\n        public override void OnApplyTemplate()\n        {\n            base.OnApplyTemplate();\n\n            editableTextBox = GetTemplateChild(\"PART_EditableTextBox\") as TextBox;\n            if (editableTextBox == null)\n                throw new InvalidOperationException(\"A part named 'PART_EditableTextBox' must be present in the ControlTemplate, and must be of type 'Stride.Core.Presentation.Controls.Input.TextBox'.\");\n\n            listBox = GetTemplateChild(\"PART_ListBox\") as ListBox;\n            if (listBox == null)\n                throw new InvalidOperationException(\"A part named 'PART_ListBox' must be present in the ControlTemplate, and must be of type 'ListBox'.\");\n\n            editableTextBox.TextChanged += EditableTextBoxTextChanged;\n            editableTextBox.PreviewKeyDown += EditableTextBoxPreviewKeyDown;\n            editableTextBox.Validating += EditableTextBoxValidating;\n            editableTextBox.Validated += EditableTextBoxValidated;\n            editableTextBox.Cancelled += EditableTextBoxCancelled;\n            editableTextBox.LostFocus += EditableTextBoxLostFocus;\n            listBox.MouseUp += ListBoxMouseUp;\n        }\n\n        protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)\n        {\n            base.OnGotKeyboardFocus(e);\n            if (OpenDropDownOnFocus && !listBoxClicking)\n            {\n                IsDropDownOpen = true;\n            }\n            listBoxClicking = false;","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/Controls/FilteringComboBox.cs#L226-L262","documentation":"FilteringComboBox.OnApplyTemplate also requires a template part named 'PART_ListBox' of type ListBox, used to display filtered results and wire selection handling. If GetTemplateChild('PART_ListBox') returns null or a non-ListBox, the control throws InvalidOperationException. This error fires after the PART_EditableTextBox check passes.","triggerScenarios":"Applying a ControlTemplate for FilteringComboBox containing PART_EditableTextBox but missing an element named PART_ListBox, or where the name is on a different control type (e.g. ItemsControl, ComboBox).","commonSituations":"Hand-written templates omitting the results list; renaming the part; using a derived/custom list control that doesn't derive from ListBox.","solutions":["Add an element named PART_ListBox of type ListBox to the ControlTemplate.","If a custom list type is used, make it derive from ListBox or switch back to ListBox.","Start from the default FilteringComboBox template in the theme and modify incrementally."],"exampleFix":"<!-- before -->\n<ItemsControl x:Name=\"PART_ListBox\"/>\n<!-- after -->\n<ListBox x:Name=\"PART_ListBox\"/>","handlingStrategy":"validation","validationCode":"var lb = combo.Template?.FindName(\"PART_ListBox\", combo);\nif (lb is not System.Windows.Controls.ListBox)\n    throw new InvalidOperationException(\"Template needs a ListBox named PART_ListBox.\");","typeGuard":"bool HasListBoxPart(FilteringComboBox combo) => combo.Template?.FindName(\"PART_ListBox\", combo) is System.Windows.Controls.ListBox;","tryCatchPattern":"try { combo.ApplyTemplate(); }\ncatch (InvalidOperationException ex) { log.Error(\"FilteringComboBox template missing PART_ListBox\", ex); }","preventionTips":["Always include a ListBox named PART_ListBox in custom templates.","Verify derived list controls inherit from ListBox before naming them PART_ListBox.","Test template application (ApplyTemplate) in UI smoke tests."],"tags":["wpf","control-template","template-parts"],"backgroundTag":"resource-not-found","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"}