{"record":{"id":"c47a93dd001b2483","repo":"dotnet/wpf","slug":"sr-conditionvalueofexpressionnotsupported-trigger","errorCode":null,"errorMessage":"SR.ConditionValueOfExpressionNotSupported","messagePattern":"SR\\.ConditionValueOfExpressionNotSupported","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Trigger.cs","lineNumber":85,"sourceCode":"                if (IsSealed)\n                {\n                    throw new InvalidOperationException(SR.Format(SR.CannotChangeAfterSealed, \"Trigger\"));\n                }\n\n                if (value is NullExtension)\n                {\n                    value = null;\n                }\n\n                if (value is MarkupExtension)\n                {\n                    throw new ArgumentException(SR.Format(SR.ConditionValueOfMarkupExtensionNotSupported,\n                                                       value.GetType().Name));\n                }\n\n                if (value is Expression)\n                {\n                    throw new ArgumentException(SR.ConditionValueOfExpressionNotSupported);\n                }\n\n                _value = value;\n            }\n        }\n\n        /// <summary>\n        /// The x:Name of the object whose property shall\n        /// trigger the associated setters to be applied.\n        /// If null, then this is the object being Styled\n        /// and not anything under its Template Tree.\n        /// </summary>\n        [DefaultValue(null)]\n        [Ambient]\n        public string SourceName\n        {\n            get\n            {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Trigger.cs#L67-L103","documentation":"Trigger.Value also rejects Expression instances (the base of BindingExpression-style dynamic values). Trigger conditions must be static comparable values; expressions/bindings are not supported, so ArgumentException with SR.ConditionValueOfExpressionNotSupported is thrown.","triggerScenarios":"Assigning a Binding/Expression object (e.g. binding.Expression or a Binding instance that produced an Expression) to Trigger.Value in code.","commonSituations":"Developers attempting data-bound conditions on a plain Trigger instead of DataTrigger; copying Setter-like binding patterns into condition values.","solutions":["Use a DataTrigger with Binding for data-driven conditions instead of a Trigger with an Expression value.","Provide a plain constant value for Trigger.Value.","Evaluate the expression/binding in code and set the computed result as Value."],"exampleFix":"// before\ntrigger.Value = myBinding; // throws\n// after\nvar dataTrigger = new DataTrigger { Binding = myBinding, Value = true };\nstyle.Triggers.Add(dataTrigger);","handlingStrategy":"type-guard","validationCode":"if (value is Expression) throw new ArgumentException(\"Trigger.Value cannot be an Expression; use DataTrigger with Binding instead\");","typeGuard":"static bool IsValidConditionValue(object v) => v is not Expression and not MarkupExtension;","tryCatchPattern":"try { trigger.Value = value; }\ncatch (ArgumentException) { style.Triggers.Add(new DataTrigger { Binding = binding, Value = expected }); }","preventionTips":["Use DataTrigger (not Trigger) whenever the condition involves a Binding","Keep Trigger.Value limited to constants","Review code that copies Setter binding patterns into conditions"],"tags":["wpf","trigger","binding","argument-exception"],"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"}