{"record":{"id":"9df0164580fb2c29","repo":"dotnet/wpf","slug":"sr-format-sr-invalidpropertyvalue-value-property-name","errorCode":null,"errorMessage":"SR.Format(SR.InvalidPropertyValue, _value, _property.Name)","messagePattern":"SR\\.Format\\(SR\\.InvalidPropertyValue, _value, _property\\.Name\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Trigger.cs","lineNumber":199,"sourceCode":"                throw new ArgumentException(SR.Format(SR.UnexpectedParameterType, o.GetType(), typeof(Setter)), nameof(o));\n            }\n\n            return setter;\n        }\n\n        internal sealed override void Seal()\n        {\n            if (IsSealed)\n            {\n                return;\n            }\n\n            if (_property != null)\n            {\n                // Ensure valid condition\n                if (!_property.IsValidValue(_value))\n                {\n                    throw new InvalidOperationException(SR.Format(SR.InvalidPropertyValue, _value, _property.Name ));\n                }\n            }\n\n            // Freeze the condition for the trigger\n            StyleHelper.SealIfSealable(_value);\n\n            // Process the _setters collection: Copy values into PropertyValueList and seal the Setter objects.\n            ProcessSettersCollection(_setters);\n\n            // Build conditions array from collection\n            TriggerConditions = new TriggerCondition[] {\n                new TriggerCondition(\n                    _property,\n                    LogicalOp.Equals,\n                    _value,\n                    _sourceName ?? StyleHelper.SelfName) };\n\n            // Set Condition for all property triggers","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Trigger.cs#L181-L217","documentation":"During Trigger.Seal(), if Property is set, the framework validates that the condition Value is a valid value for that dependency property via IsValidValue. An out-of-domain value (wrong type or outside enum coercion) throws InvalidOperationException with SR.InvalidPropertyValue showing the value and property name.","triggerScenarios":"trigger.Property = UIElement.OpacityProperty; trigger.Value = \"high\"; then Seal()/style application — the string is not a valid double for Opacity. Also enum values of the wrong enum type.","commonSituations":"Assigning a value of the wrong type for the property (string where double/enum expected); copy-pasting values across properties; values typed from parsed config strings.","solutions":["Set a Value whose type matches the property (e.g. 0.5 for Opacity, proper enum member for enums).","Use the property's type converter to convert strings first (e.g. TypeDescriptor.GetConverter(prop.PropertyType).ConvertFromString(s)) and verify IsValidValue yourself.","Validate before sealing: if (!prop.IsValidValue(value)) fix or reject the value."],"exampleFix":"// before\ntrigger.Property = UIElement.OpacityProperty;\ntrigger.Value = \"high\"; // throws on Seal\n// after\ntrigger.Property = UIElement.OpacityProperty;\ntrigger.Value = 0.5;","handlingStrategy":"validation","validationCode":"if (trigger.Property != null && !trigger.Property.IsValidValue(value))\n    throw new InvalidOperationException($\"{value} is not valid for {trigger.Property.Name}\");","typeGuard":"static bool IsValidFor(Trigger t) => t.Property == null || t.Property.IsValidValue(t.Value);","tryCatchPattern":"try { style.Seal(); /* or trigger seal via style use */ }\ncatch (InvalidOperationException ex) { log.Error($\"Trigger condition invalid: {ex.Message}\"); }","preventionTips":["Match value type to the dependency property's type exactly","Convert strings with the property's TypeConverter before assigning","Call DependencyProperty.IsValidValue as a pre-flight check"],"tags":["wpf","trigger","validation","invalid-operation","dependency-property"],"backgroundTag":"invalid-config-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}