{"record":{"id":"8938a4f2239ce883","repo":"dotnet/wpf","slug":"sr-nullpropertyillegal","errorCode":null,"errorMessage":"SR.NullPropertyIllegal","messagePattern":"SR\\.NullPropertyIllegal","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Condition.cs","lineNumber":193,"sourceCode":"        {\n            if (_sealed)\n            {\n                return;\n            }\n\n            _sealed = true;\n\n            // Ensure valid condition\n            if (_property != null && _binding != null)\n                throw new InvalidOperationException(SR.ConditionCannotUseBothPropertyAndBinding);\n\n            switch (type)\n            {\n                case ValueLookupType.Trigger:\n                case ValueLookupType.PropertyTriggerResource:\n                    if (_property == null)\n                    {\n                        throw new InvalidOperationException(SR.Format(SR.NullPropertyIllegal, \"Property\"));\n                    }\n\n                    if (!_property.IsValidValue(_value))\n                    {\n                        throw new InvalidOperationException(SR.Format(SR.InvalidPropertyValue, _value, _property.Name));\n                    }\n                    break;\n\n                case ValueLookupType.DataTrigger:\n                case ValueLookupType.DataTriggerResource:\n                    if (_binding == null)\n                    {\n                        throw new InvalidOperationException(SR.Format(SR.NullPropertyIllegal, \"Binding\"));\n                    }\n                    break;\n\n                default:\n                    throw new InvalidOperationException(SR.Format(SR.UnexpectedValueTypeForCondition, type));","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Condition.cs#L175-L211","documentation":"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).","triggerScenarios":"Sealing a Condition whose Property was never set while lookup type is Trigger or PropertyTriggerResource (e.g. <Condition Value=\"True\"/> without Property in XAML).","commonSituations":"XAML parse errors on incomplete Condition elements; code-built Conditions missing Property before adding to a Trigger's Conditions collection.","solutions":["Set Condition.Property (and Value) before the style/trigger is sealed","Use a data trigger with Binding when no property condition is intended"],"exampleFix":"// before\nvar c = new Condition(null, true);\n// after\nvar c = new Condition(Selector.IsSelectedProperty, true);","handlingStrategy":"validation","validationCode":"if (condition.Property == null)\n    throw new InvalidOperationException(\"Property-trigger Condition requires a Property\");","typeGuard":"bool HasProperty(Condition c) => c.Property != null;","tryCatchPattern":"try { trigger.Conditions.Add(condition); style.Seal(); }\ncatch (InvalidOperationException ex) { /* supply missing Property */ }","preventionTips":["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."],"tags":["wpf","triggers","null-value"],"backgroundTag":"missing-required-argument","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"}