{"record":{"id":"a8b53d1eda8e6c72","repo":"stride3d/stride","slug":"a-part-named-part-contenthost-must-be-present-in-the","errorCode":null,"errorMessage":"A part named 'PART_ContentHost' must be present in the ControlTemplate, and must be of type 'ScrollViewer'.","messagePattern":"A part named 'PART_ContentHost' must be present in the ControlTemplate, and must be of type 'ScrollViewer'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/Controls/NumericTextBox.cs","lineNumber":275,"sourceCode":"        /// </summary>\n        public event EventHandler<RepeatButtonPressedRoutedEventArgs> RepeatButtonReleased { add { AddHandler(RepeatButtonReleasedEvent, value); } remove { RemoveHandler(RepeatButtonReleasedEvent, value); } }\n\n        /// <inheritdoc/>\n        public override void OnApplyTemplate()\n        {\n            base.OnApplyTemplate();\n\n            increaseButton = GetTemplateChild(\"PART_IncreaseButton\") as RepeatButton;\n            if (increaseButton == null)\n                throw new InvalidOperationException(\"A part named 'PART_IncreaseButton' must be present in the ControlTemplate, and must be of type 'RepeatButton'.\");\n\n            decreaseButton = GetTemplateChild(\"PART_DecreaseButton\") as RepeatButton;\n            if (decreaseButton == null)\n                throw new InvalidOperationException(\"A part named 'PART_DecreaseButton' must be present in the ControlTemplate, and must be of type 'RepeatButton'.\");\n\n            contentHost = GetTemplateChild(\"PART_ContentHost\") as ScrollViewer;\n            if (contentHost == null)\n                throw new InvalidOperationException(\"A part named 'PART_ContentHost' must be present in the ControlTemplate, and must be of type 'ScrollViewer'.\");\n\n            var increasePressedWatcher = new DependencyPropertyWatcher(increaseButton);\n            increasePressedWatcher.RegisterValueChangedHandler(ButtonBase.IsPressedProperty, RepeatButtonIsPressedChanged);\n            var decreasePressedWatcher = new DependencyPropertyWatcher(decreaseButton);\n            decreasePressedWatcher.RegisterValueChangedHandler(ButtonBase.IsPressedProperty, RepeatButtonIsPressedChanged);\n            var textValue = FormatValue(Value);\n\n            SetCurrentValue(TextProperty, textValue);\n        }\n\n        /// <summary>\n        /// Raised when the <see cref=\"Value\"/> property has changed.\n        /// </summary>\n        protected virtual void OnValueChanged(double? oldValue, double? newValue)\n        {\n        }\n\n        /// <inheritdoc/>","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/Controls/NumericTextBox.cs#L257-L293","documentation":"NumericTextBox.OnApplyTemplate requires a ScrollViewer named 'PART_ContentHost' that hosts the editable text. When the applied template lacks it or uses a different element type, GetTemplateChild returns null and an InvalidOperationException is thrown.","triggerScenarios":"Custom ControlTemplate for NumericTextBox without a ScrollViewer named PART_ContentHost; part renamed; replaced with a TextBox or ContentPresenter directly.","commonSituations":"Re-skinning numeric editors and omitting the content host; templates derived from plain TextBox styles that name the host differently; edits that convert the ScrollViewer into a Border.","solutions":["Add <ScrollViewer x:Name=\"PART_ContentHost\"/> to the ControlTemplate (it must contain the text host)","Keep the exact case-sensitive name PART_ContentHost","Ensure the element is a ScrollViewer, not another container type","Derive your template from the default NumericTextBox template"],"exampleFix":"<!-- before -->\n<Grid>\n  <TextBox x:Name=\"PART_ContentHost\"/>\n</Grid>\n<!-- after -->\n<Grid>\n  <ScrollViewer x:Name=\"PART_ContentHost\"/>\n</Grid>","handlingStrategy":"validation","validationCode":"var host = numericTextBox.Template?.FindName(\"PART_ContentHost\", numericTextBox) as ScrollViewer;\nif (host == null) throw new InvalidOperationException(\"NumericTextBox template missing PART_ContentHost (ScrollViewer)\");","typeGuard":"bool HasContentHost(NumericTextBox c) => c.Template?.FindName(\"PART_ContentHost\", c) is ScrollViewer;","tryCatchPattern":"try { control.ApplyTemplate(); }\ncatch (InvalidOperationException ex) { log.Error(ex, \"Invalid NumericTextBox template; restoring default style\"); control.Style = null; }","preventionTips":["Always include a ScrollViewer named PART_ContentHost in templates","Do not replace the host with TextBox/ContentPresenter directly","Re-validate templates when upgrading the library","Smoke-test editable behavior with custom themes"],"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"}