dotnet/wpf · error · InvalidOperationException
SR.NullPropertyIllegal
Error message
SR.NullPropertyIllegal
What it means
InvalidOperationException from Condition.Seal for trigger-style lookups: neither Property nor Binding was set on the Condition, so the sealed trigger condition has nothing to evaluate and is invalid (the NullPropertyIllegal sentinel naming the missing property).
Solutions
- Set Condition.Property (and Value) before the style/trigger is sealed
- Use a data trigger with Binding when no property condition is intended
Example fix
// before var c = new Condition(null, true); // after var c = new Condition(Selector.IsSelectedProperty, true);
Defensive patterns
Strategy: validation
Validate before calling
if (condition.Property == null)
throw new InvalidOperationException("Property-trigger Condition requires a Property"); Type guard
bool HasProperty(Condition c) => c.Property != null;
Try / catch
try { trigger.Conditions.Add(condition); style.Seal(); }
catch (InvalidOperationException ex) { /* supply missing Property */ } Prevention
- Always set Property when building property-trigger conditions.
- Validate condition completeness before adding to triggers.
- In XAML, include the Property attribute on every Condition in a Trigger.
When it happens
Trigger: Sealing a Condition whose Property was never set while lookup type is Trigger or PropertyTriggerResource (e.g. <Condition Value="True"/> without Property in XAML).
Common situations: XAML parse errors on incomplete Condition elements; code-built Conditions missing Property before adding to a Trigger's Conditions collection.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- SR.CannotChangeAfterSealed
- SR.ConditionCannotUseBothPropertyAndBinding
- SR.ConditionValueOfExpressionNotSupported
- SR.ConditionValueOfMarkupExtensionNotSupported
- SR.Format(SR.CannotChangeAfterSealed, "TriggerCollection")
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/8938a4f2239ce883.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Condition.cs:193
{
if (_sealed)
{
return;
}
_sealed = true;
// Ensure valid condition
if (_property != null && _binding != null)
throw new InvalidOperationException(SR.ConditionCannotUseBothPropertyAndBinding);
switch (type)
{
case ValueLookupType.Trigger:
case ValueLookupType.PropertyTriggerResource:
if (_property == null)
{
throw new InvalidOperationException(SR.Format(SR.NullPropertyIllegal, "Property"));
}
if (!_property.IsValidValue(_value))
{
throw new InvalidOperationException(SR.Format(SR.InvalidPropertyValue, _value, _property.Name));
}
break;
case ValueLookupType.DataTrigger:
case ValueLookupType.DataTriggerResource:
if (_binding == null)
{
throw new InvalidOperationException(SR.Format(SR.NullPropertyIllegal, "Binding"));
}
break;
default:
throw new InvalidOperationException(SR.Format(SR.UnexpectedValueTypeForCondition, type));View on GitHub (pinned to 81131a70a4)