{"record":{"id":"39ff77fca24cf27c","repo":"dotnet/wpf","slug":"sr-invalidpropertyvalue","errorCode":null,"errorMessage":"SR.InvalidPropertyValue","messagePattern":"SR\\.InvalidPropertyValue","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Condition.cs","lineNumber":51,"sourceCode":"            // Call Forwarded\n        }\n\n        /// <summary>\n        ///     Constructor for creating a Condition with the given property\n        /// and value instead of creating an empty one and setting values later.\n        /// </summary>\n        /// <remarks>\n        ///     This constructor does parameter validation, which before doesn't\n        /// happen until Seal() is called.  We can do it here because we get\n        /// both at the same time.\n        /// </remarks>\n        public Condition( DependencyProperty conditionProperty, object conditionValue, string sourceName )\n        {\n            ArgumentNullException.ThrowIfNull(conditionProperty);\n\n            if (!conditionProperty.IsValidValue(conditionValue))\n            {\n                throw new ArgumentException(SR.Format(SR.InvalidPropertyValue, conditionValue, conditionProperty.Name));\n            }\n\n            _property = conditionProperty;\n            Value    = conditionValue;\n            _sourceName = sourceName;\n        }\n\n        /// <summary>\n        ///     Constructor for creating a Condition with the given binding declaration.\n        /// and value.\n        /// </summary>\n        public Condition( BindingBase binding, object conditionValue )\n        {\n            ArgumentNullException.ThrowIfNull(binding);\n\n            Binding = binding;\n            Value  = conditionValue;\n        }","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Condition.cs#L33-L69","documentation":"The Condition constructor validates that conditionValue is a valid value for conditionProperty by calling DependencyProperty.IsValidValue. If the value's type is wrong or out of range for the dependency property, it throws ArgumentException (InvalidPropertyValue).","triggerScenarios":"new Condition(dp, value, ...) where value fails dp.IsValidValue — e.g. passing a string for a double property, or a value outside the property's validation range.","commonSituations":"Building Trigger/ MultiTrigger conditions in code with loosely-typed values; type mismatches after refactoring a property's CLR type; strings used for enum properties that need actual enum values.","solutions":["Use a value that satisfies conditionProperty.IsValidValue (e.g. proper CLR type, enum cast, valid range)","Use dp.PropertyType to coerce/convert the value (e.g. TypeConverter or Enum.Parse) before constructing the Condition","Validate with conditionProperty.IsValidValue(value) before calling the constructor"],"exampleFix":"// before\nnew Condition(UIElement.VisibilityProperty, \"Visible\"); // wrong type\n// after\nnew Condition(UIElement.VisibilityProperty, Visibility.Visible);","handlingStrategy":"validation","validationCode":"if (!conditionProperty.IsValidValue(conditionValue)) throw new ArgumentException($\"Value {conditionValue} invalid for {conditionProperty.Name}\");","typeGuard":"bool IsValidConditionValue(DependencyProperty dp, object v) => dp.IsValidValue(v);","tryCatchPattern":"try { var c = new Condition(dp, value); } catch (ArgumentException ex) { /* coerce value via dp.PropertyType and retry */ }","preventionTips":["Coerce values to dp.PropertyType before constructing Conditions","Use actual enum values, not strings","Call IsValidValue as a pre-check in helper code"],"tags":["wpf","triggers","validation","argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}