{"record":{"id":"ebe9636db74f183f","repo":"dotnet/wpf","slug":"sr-conditionvalueofmarkupextensionnotsupported","errorCode":null,"errorMessage":"SR.ConditionValueOfMarkupExtensionNotSupported","messagePattern":"SR\\.ConditionValueOfMarkupExtensionNotSupported","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Condition.cs","lineNumber":134,"sourceCode":"        }\n\n        /// <summary>\n        ///     Value of the condition (equality check)\n        /// </summary>\n        [TypeConverter(typeof(System.Windows.Markup.SetterTriggerConditionValueConverter))]\n        public object Value\n        {\n            get { return _value; }\n            set\n            {\n                if (_sealed)\n                {\n                    throw new InvalidOperationException(SR.Format(SR.CannotChangeAfterSealed, \"Condition\"));\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>","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Condition.cs#L116-L152","documentation":"Condition.Value does not accept a MarkupExtension (e.g. StaticResource, Binding) — the trigger evaluation engine needs an actual evaluated value, not deferred markup. Assigning one throws ArgumentException (ConditionValueOfMarkupExtensionNotSupported) with the extension type name.","triggerScenarios":"Setting Condition.Value to a MarkupExtension instance, typically when building conditions in code with resource lookups instead of resolved values.","commonSituations":"Porting XAML trigger values to C# and copying the markup extension object instead of its evaluated result; using FindResource/StaticResource incorrectly.","solutions":["Resolve the markup extension first (e.g. FindResource for StaticResource) and assign the actual value","Assign the concrete CLR/enum value matching the property type","Never pass Binding/StaticResource/DynamicResource extension objects to Condition.Value"],"exampleFix":"// before\ncondition.Value = new StaticResourceExtension(\"MyBrush\"); // throws\n// after\ncondition.Value = element.FindResource(\"MyBrush\");","handlingStrategy":"validation","validationCode":"if (value is MarkupExtension ext) value = ResolveExtension(ext); // e.g. FindResource for StaticResourceExtension\nif (value is Expression) throw new ArgumentException(\"Expressions are not valid Condition values\");","typeGuard":"bool IsDeferredValue(object v) => v is MarkupExtension or Expression; // reject these before assigning","tryCatchPattern":"try { condition.Value = v; } catch (ArgumentException ex) when (ex.Message.Contains(\"MarkupExtension\")) { /* resolve resource and retry */ }","preventionTips":["Resolve MarkupExtensions before assigning Condition.Value","Use FindResource/TryFindResource instead of StaticResourceExtension in code","Never pass Expression objects into Condition.Value"],"tags":["wpf","triggers","markup-extension","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-21T21:30:21.729Z"}