{"record":{"id":"6d80d856301be322","repo":"dotnet/wpf","slug":"sr-missingtriggerproperty","errorCode":null,"errorMessage":"SR.MissingTriggerProperty","messagePattern":"SR\\.MissingTriggerProperty","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/StyleHelper.cs","lineNumber":551,"sourceCode":"            case ValueLookupType.Trigger:\n            case ValueLookupType.PropertyTriggerResource:\n                {\n                    if( propertyValue.Conditions != null )\n                    {\n                        // Record the current property as a dependent to each on of the\n                        // properties in the condition. This is to facilitate the invalidation\n                        // of the current property in the event that any one of the properties\n                        // in the condition change. This will allow the current property to get\n                        // re-evaluated.\n                        for (int i = 0; i < propertyValue.Conditions.Length; i++)\n                        {\n                            int sourceChildIndex = propertyValue.Conditions[i].SourceChildIndex;\n                            triggerSourceRecordFromChildIndex.EnsureIndex(sourceChildIndex);\n                            ItemStructMap<TriggerSourceRecord> triggerSourceRecordMap = triggerSourceRecordFromChildIndex[sourceChildIndex];\n\n                            if (propertyValue.Conditions[i].Property == null)\n                            {\n                                throw new InvalidOperationException(SR.MissingTriggerProperty);\n                            }\n                            int index = triggerSourceRecordMap.EnsureEntry(propertyValue.Conditions[i].Property.GlobalIndex);\n                            AddPropertyDependent(childIndex, propertyValue.Property,\n                                ref triggerSourceRecordMap.Entries[index].Value.ChildPropertyDependents);\n\n                            // Store the triggerSourceRecordMap back into the list after it has been updated\n                            triggerSourceRecordFromChildIndex[sourceChildIndex] = triggerSourceRecordMap;\n                        }\n\n                        // If value is a resource reference, add dependent on resource changes\n                        if ((ValueLookupType)propertyValue.ValueType == ValueLookupType.PropertyTriggerResource)\n                        {\n                            AddResourceDependent(childIndex, propertyValue.Property, propertyValue.ValueInternal, ref resourceDependents);\n                        }\n                    }\n\n                    // values in a Trigger may require per-instance storage\n                    if ((ValueLookupType)propertyValue.ValueType != ValueLookupType.PropertyTriggerResource)","sourceCodeStart":533,"sourceCodeEnd":569,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/StyleHelper.cs#L533-L569","documentation":"StyleHelper.UpdateTables throws this while registering a property trigger: a TriggerAction/Setter whose Condition has a null Property was encountered. Every property-trigger condition must name a DependencyProperty to watch; the library throws InvalidOperationException at style (or template) attach time because a condition without a property can never be evaluated.","triggerScenarios":"Attaching a Style/FrameworkTemplate whose Triggers contain a Trigger or MultiTrigger with a Condition whose Property is null — typically constructed in code with new Condition() and never assigning .Property, or XAML omitting the Property attribute while only supplying Value.","commonSituations":"Hand-building triggers in C# (e.g. condition = new Condition { Value = true };) and forgetting Property; deserializing BAML/XAML where the Property attribute was dropped; converter-generated styles from tooling emitting incomplete conditions.","solutions":["Assign Condition.Property to a valid DependencyProperty before the style is applied, e.g. cond.Property = UIElement.IsEnabledProperty","In XAML ensure each <Condition Property=\"...\" Value=\"...\"/> has the Property attribute","If a condition should not test a property, remove it and express the logic in the Setter or a data trigger","Add a debug validation pass over style.Triggers before assigning the style to the element"],"exampleFix":"// before\nvar cond = new Condition { Value = true };\nvar trg = new Trigger(); trg.Conditions.Add(cond);\n// after\nvar cond = new Condition { Property = UIElement.IsEnabledProperty, Value = true };\nvar trg = new Trigger(); trg.Setters.Add(new Setter(OpacityProperty, 0.5)); trg.Conditions.Add(cond);","handlingStrategy":"validation","validationCode":"foreach (TriggerBase t in style.Triggers)\n    if (t is Trigger tr)\n        foreach (Condition c in tr.Conditions)\n            if (c.Property == null) throw new InvalidOperationException(\"Condition.Property missing in trigger \" + t.GetType().Name);","typeGuard":null,"tryCatchPattern":"try { element.Style = style; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"property\")) { /* log style definition error */ }","preventionTips":["Always set Condition.Property when constructing triggers in code","Validate trigger collections before assigning styles","Prefer XAML for trigger definitions so the compiler validates attributes"],"tags":["wpf","styles","triggers","invalid-argument"],"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"}