{"record":{"id":"1d286fd2371eae4c","repo":"stride3d/stride","slug":"the-value-of-the-property-e-property-name-cannot-be","errorCode":null,"errorMessage":"The value of the property '{e.Property.Name}' cannot be different from the value '{metadata.DefaultValue}'","messagePattern":"The value of the property '(.+?)' cannot be different from the value '(.+?)'","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/Controls/NumericTextBox.cs","lineNumber":562,"sourceCode":"        }\n\n        private static void OnSmallDecreaseCommand([NotNull] object sender, ExecutedRoutedEventArgs e)\n        {\n            UpdateValueCommand(sender, x => (x.Value ?? x.Maximum) - x.SmallChange);\n        }\n\n        private static void OnResetValueCommand([NotNull] object sender, ExecutedRoutedEventArgs e)\n        {\n            UpdateValueCommand(sender, x => 0.0, false);\n        }\n\n        private static void OnForbiddenPropertyChanged([NotNull] DependencyObject d, DependencyPropertyChangedEventArgs e)\n        {\n            var metadata = e.Property.GetMetadata(d);\n            if (!Equals(e.NewValue, metadata.DefaultValue))\n            {\n                var message = $\"The value of the property '{e.Property.Name}' cannot be different from the value '{metadata.DefaultValue}'\";\n                throw new InvalidOperationException(message);\n            }\n        }\n    }\n}\n","sourceCodeStart":544,"sourceCodeEnd":567,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/Controls/NumericTextBox.cs#L544-L567","documentation":"NumericTextBox registers OnForbiddenPropertyChanged on certain dependency properties (e.g. readonly/format-related) whose value must never change from the metadata default. Setting such a property to any other value in XAML or code raises this InvalidOperationException immediately.","triggerScenarios":"Assigning a local value, style setter, binding, or animation to a forbidden DP of NumericTextBox (any value different from its DefaultMetadata DefaultValue).","commonSituations":"Setting properties like IsReadOnly/allow-drop style flags in a Style targeting NumericTextBox; copy-pasted setters from a parent type; XAML designers emitting explicit values that differ from defaults.","solutions":["Remove the property setter/binding that changes the forbidden property, or set it back to its default value","Find which property via e.Property in the stack/message and check whether it is legitimately settable on this control","Set the property on an inner element of your template instead of on NumericTextBox itself","If you own the control, move the property to the list of settable ones rather than marking it forbidden"],"exampleFix":"<!-- before -->\n<Style TargetType=\"ntb:NumericTextBox\">\n  <Setter Property=\"IsReadOnly\" Value=\"True\"/>\n</Style>\n<!-- after: apply the behavior where it is supported -->\n<Style TargetType=\"ntb:NumericTextBox\">\n  <!-- remove the forbidden setter -->\n  <Setter Property=\"Background\" Value=\"LightYellow\"/>\n</Style>","handlingStrategy":"validation","validationCode":"// verify a forbidden property is at its default before setting style\nvar meta = NumericTextBox.IsReadOnlyProperty.GetMetadata(typeof(NumericTextBox));\nif (!Equals(newValue, meta.DefaultValue)) throw new InvalidOperationException($\"{nameof(NumericTextBox.IsReadOnly)} cannot differ from default {meta.DefaultValue}\");","typeGuard":null,"tryCatchPattern":"try { ApplyStyle(); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"The value of the property\")) { log.Error(ex, \"Style sets a forbidden property on NumericTextBox\"); throw; }","preventionTips":["Read the control's metadata defaults before styling","Do not set forbidden properties via styles, bindings, or animations","Apply behavioral flags on inner template elements instead","Keep XAML explicit setters minimal — rely on defaults"],"tags":["wpf","dependency-property","readonly"],"backgroundTag":"invalid-config-value","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"}