dotnet/wpf · error · ArgumentException
SR.ConditionValueOfExpressionNotSupported
Error message
SR.ConditionValueOfExpressionNotSupported
What it means
Setting the Value of a WPF trigger Condition to an Expression (the result of a dynamic markup extension such as {Binding}) is not supported; conditions must have static, sealable values. The Condition class throws ArgumentException because dynamic expressions cannot be evaluated during style/trigger sealing.
Solutions
- Use a static literal value for the condition Value (e.g. "True", a fixed enum value or color).
- If dynamic behavior is needed, use a DataTrigger with a Binding in the Condition's Binding property rather than an Expression as Value.
- Compute the desired value before assigning and assign the concrete result, not the expression.
Example fix
// before new Condition(Selector.IsSelectedProperty, someBinding.Expression); // after new Condition(Selector.IsSelectedProperty, true);
Defensive patterns
Strategy: validation
Validate before calling
if (condition.Value is Expression)
throw new InvalidOperationException("Condition.Value must be a static value, not an Expression"); Type guard
bool IsValidConditionValue(object v) => v is not Expression;
Prevention
- Never bind a trigger condition Value with {Binding}; use static literals.
- Use DataTrigger Binding conditions for dynamic data-driven behavior.
- Check the value with 'is Expression' before assigning in code.
When it happens
Trigger: Assigning a value produced by a markup extension that returns an Expression (e.g. condition.Value = someBindingExpression) in code, or XAML where a Binding is used as the condition value.
Common situations: Developers try to write <Condition Property="IsSelected" Value="{Binding ...}" /> or set Value in code to a dynamic value, expecting triggers to re-evaluate dynamically.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- InvalidEnumArgumentException("value", (int) value…
- InvalidEnumArgumentException("value", (int) value…
- SR.BindingExpressionIsDetached
- SR.CannotChangeAfterSealed
- SR.ConditionCannotUseBothPropertyAndBinding
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/602cead8daf6a24a.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Condition.cs:140
public object Value
{
get { return _value; }
set
{
if (_sealed)
{
throw new InvalidOperationException(SR.Format(SR.CannotChangeAfterSealed, "Condition"));
}
if (value is MarkupExtension)
{
throw new ArgumentException(SR.Format(SR.ConditionValueOfMarkupExtensionNotSupported,
value.GetType().Name));
}
if(value is Expression)
{
throw new ArgumentException(SR.ConditionValueOfExpressionNotSupported);
}
_value = value;
}
}
/// <summary>
/// The x:Name of the object whose property shall
/// trigger the associated setters to be applied.
/// If null, then this is the object being Styled
/// and not anything under its Template Tree.
/// </summary>
[DefaultValue(null)]
public string SourceName
{
get
{
return _sourceName;View on GitHub (pinned to 81131a70a4)