{"record":{"id":"1092dd7e98dfa6c3","repo":"stride3d/stride","slug":"a-part-named-editabletextboxpartname-must-be-present-in-the","errorCode":null,"errorMessage":"A part named '{EditableTextBoxPartName}' must be present in the ControlTemplate, and must be of type '{typeof(TextBox).FullName}'.","messagePattern":"A part named '(.+?)' must be present in the ControlTemplate, and must be of type '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/Controls/SearchComboBox.cs","lineNumber":151,"sourceCode":"        /// Gets or sets whether the drop down is open.\n        /// </summary>\n        public bool IsDropDownOpen { get { return (bool)GetValue(IsDropDownOpenProperty); } set { SetValue(IsDropDownOpenProperty, value.Box()); } }\n        /// <summary>\n        /// Gets or sets the search text of this <see cref=\"SearchComboBox\"/>\n        /// </summary>\n        public string SearchText { get { return (string)GetValue(SearchTextProperty); } set { SetValue(SearchTextProperty, value); } }\n        /// <summary>\n        /// Gets or sets the content to display when the TextBox is empty.\n        /// </summary>\n        public object WatermarkContent { get { return GetValue(WatermarkContentProperty); } set { SetValue(WatermarkContentProperty, value); } }\n\n        public override void OnApplyTemplate()\n        {\n            base.OnApplyTemplate();\n\n            editableTextBox = GetTemplateChild(EditableTextBoxPartName) as TextBox;\n            if (editableTextBox == null)\n                throw new InvalidOperationException($\"A part named '{EditableTextBoxPartName}' must be present in the ControlTemplate, and must be of type '{typeof(TextBox).FullName}'.\");\n\n            listBox = GetTemplateChild(ListBoxPartName) as ListBox;\n            if (listBox == null)\n                throw new InvalidOperationException($\"A part named '{ListBoxPartName}' must be present in the ControlTemplate, and must be of type '{nameof(ListBox)}'.\");\n            \n            editableTextBox.LostFocus += EditableTextBoxLostFocus;\n            editableTextBox.PreviewKeyDown += EditableTextBoxPreviewKeyDown;\n            editableTextBox.PreviewKeyUp += EditableTextBoxPreviewKeyUp;\n            editableTextBox.Validated += EditableTextBoxValidated;\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;","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/Controls/SearchComboBox.cs#L133-L169","documentation":"SearchComboBox.OnApplyTemplate fetches its editable TextBox part (EditableTextBoxPartName) and throws InvalidOperationException if it is absent or not a TextBox, since search-as-you-type behavior depends on that control.","triggerScenarios":"Applying a custom ControlTemplate for SearchComboBox missing the editable TextBox part; wrong x:Name; using a non-TextBox element such as TextBlock.","commonSituations":"Re-templating combo boxes for theming; templates copied from stock ComboBox where the part is named PART_EditableTextBox differently; trimming template parts deemed unnecessary.","solutions":["Add a TextBox named per EditableTextBoxPartName (typically PART_EditableTextBox) to the ControlTemplate","Match the part name exactly and case-sensitively","Use a real TextBox element (search/keyboard handling attaches to it)","Base the template on the default SearchComboBox template"],"exampleFix":"<!-- before -->\n<ControlTemplate TargetType=\"scb:SearchComboBox\">\n  <ToggleButton x:Name=\"PART_ToggleButton\"/>\n</ControlTemplate>\n<!-- after -->\n<ControlTemplate TargetType=\"scb:SearchComboBox\">\n  <Grid>\n    <ToggleButton x:Name=\"PART_ToggleButton\"/>\n    <TextBox x:Name=\"PART_EditableTextBox\"/>\n  </Grid>\n</ControlTemplate>","handlingStrategy":"validation","validationCode":"var tb = searchComboBox.Template?.FindName(\"PART_EditableTextBox\", searchComboBox) as TextBox;\nif (tb == null) throw new InvalidOperationException(\"SearchComboBox template missing editable TextBox part\");","typeGuard":"bool HasEditableTextBox(SearchComboBox c) => c.Template?.FindName(\"PART_EditableTextBox\", c) is TextBox;","tryCatchPattern":"try { control.ApplyTemplate(); }\ncatch (InvalidOperationException ex) { log.Error(ex, \"Invalid SearchComboBox template; restoring default style\"); control.Style = null; }","preventionTips":["Preserve the editable TextBox part when re-templating","Use TextBox (not TextBlock/ComboBox inner parts)","Match part names exactly against the default template","Unit-test ApplyTemplate for every custom style shipped"],"tags":["wpf","controltemplate","xaml"],"backgroundTag":"schema-validation-failed","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}