{"record":{"id":"9d6629bc327a8852","repo":"stride3d/stride","slug":"a-part-named-part-increasebutton-must-be-present-in-the","errorCode":null,"errorMessage":"A part named 'PART_IncreaseButton' must be present in the ControlTemplate, and must be of type 'RepeatButton'.","messagePattern":"A part named 'PART_IncreaseButton' must be present in the ControlTemplate, and must be of type 'RepeatButton'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/Controls/NumericTextBox.cs","lineNumber":267,"sourceCode":"\n        /// <summary>\n        /// Raised when one of the repeat button is pressed.\n        /// </summary>\n        public event EventHandler<RepeatButtonPressedRoutedEventArgs> RepeatButtonPressed { add { AddHandler(RepeatButtonPressedEvent, value); } remove { RemoveHandler(RepeatButtonPressedEvent, value); } }\n\n        /// <summary>\n        /// Raised when one of the repeat button is released.\n        /// </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","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/Controls/NumericTextBox.cs#L249-L285","documentation":"NumericTextBox.OnApplyTemplate requires the template part 'PART_IncreaseButton' of type RepeatButton so it can wire step-up behavior. If the applied ControlTemplate lacks this named part (or it is not a RepeatButton), GetTemplateChild yields null and an InvalidOperationException is thrown.","triggerScenarios":"Applying a custom Style/ControlTemplate for NumericTextBox without a RepeatButton named PART_IncreaseButton; mistyping the part name; using a Button instead of RepeatButton.","commonSituations":"Re-skinning numeric editors; copying templates from older library versions after part renames; stripping 'unused' spinner buttons from a template.","solutions":["Add a RepeatButton named PART_IncreaseButton to the ControlTemplate","Verify exact part name 'PART_IncreaseButton' (case-sensitive)","Ensure the element type is RepeatButton (needed for auto-repeat while pressed)","Start from the default NumericTextBox template and modify rather than rewrite"],"exampleFix":"<!-- before -->\n<ControlTemplate TargetType=\"ntb:NumericTextBox\">\n  <ScrollViewer x:Name=\"PART_ContentHost\"/>\n</ControlTemplate>\n<!-- after -->\n<ControlTemplate TargetType=\"ntb:NumericTextBox\">\n  <Grid>\n    <ScrollViewer x:Name=\"PART_ContentHost\"/>\n    <RepeatButton x:Name=\"PART_IncreaseButton\"/>\n    <RepeatButton x:Name=\"PART_DecreaseButton\"/>\n  </Grid>\n</ControlTemplate>","handlingStrategy":"validation","validationCode":"var btn = numericTextBox.Template?.FindName(\"PART_IncreaseButton\", numericTextBox) as RepeatButton;\nif (btn == null) throw new InvalidOperationException(\"NumericTextBox template missing PART_IncreaseButton (RepeatButton)\");","typeGuard":"bool HasIncreaseButton(NumericTextBox c) => c.Template?.FindName(\"PART_IncreaseButton\", c) is RepeatButton;","tryCatchPattern":"try { control.ApplyTemplate(); }\ncatch (InvalidOperationException ex) { log.Error(ex, \"Invalid NumericTextBox template; restoring default style\"); control.Style = null; }","preventionTips":["Keep all PART_ elements (Increase, Decrease, ContentHost) when re-skinning","Use RepeatButton, not Button, for spinner parts","Diff your template against the default after upgrades","Force ApplyTemplate in tests to catch missing parts early"],"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"}