{"record":{"id":"63ee8ad953e986d8","repo":"dotnet/wpf","slug":"sr-conditioncannotusebothpropertyandbinding","errorCode":null,"errorMessage":"SR.ConditionCannotUseBothPropertyAndBinding","messagePattern":"SR\\.ConditionCannotUseBothPropertyAndBinding","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Condition.cs","lineNumber":88,"sourceCode":"\n        /// <summary>\n        ///     DepedencyProperty of the conditional\n        /// </summary>\n        [Ambient]\n        [DefaultValue(null)]\n        public DependencyProperty Property\n        {\n            get { return _property; }\n            set\n            {\n                if (_sealed)\n                {\n                    throw new InvalidOperationException(SR.Format(SR.CannotChangeAfterSealed, \"Condition\"));\n                }\n\n                if (_binding != null)\n                {\n                    throw new InvalidOperationException(SR.ConditionCannotUseBothPropertyAndBinding);\n                }\n\n                _property = value;\n            }\n        }\n\n        /// <summary>\n        ///     Binding of the conditional\n        /// </summary>\n        [DefaultValue(null)]\n        public BindingBase Binding\n        {\n            get { return _binding; }\n            set\n            {\n                if (_sealed)\n                {\n                    throw new InvalidOperationException(SR.Format(SR.CannotChangeAfterSealed, \"Condition\"));","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Condition.cs#L70-L106","documentation":"InvalidOperationException from Condition.Property setter: the Condition was already configured with a Binding, and a Condition cannot specify both Property and Binding — the setter guards the mutual exclusion between trigger-property and data-binding conditions.","triggerScenarios":"Assigning Condition.Property after Condition.Binding was already assigned on the same Condition instance.","commonSituations":"Reconfiguring a Condition from a binding-based to property-based check without clearing Binding first; building MultiTrigger conditions in a loop that sets both.","solutions":["Use either Property or Binding in a Condition, not both","Create a separate Condition for the property-based check"],"exampleFix":"// before\ncondition.Binding = binding;\ncondition.Property = MyProp; // throws\n// after\nvar cond1 = new Condition { Binding = binding };\nvar cond2 = new Condition(MyProp, value);","handlingStrategy":"validation","validationCode":"if (condition.Binding != null) throw new InvalidOperationException(\"Condition already has a Binding; create a new Condition for Property-based checks\");","typeGuard":null,"tryCatchPattern":"try { condition.Property = p; } catch (InvalidOperationException ex) when (ex.Message.Contains(\"Property\") || ex.Message.Contains(\"Binding\")) { /* use separate conditions */ }","preventionTips":["One Condition = one kind of check (Property XOR Binding)","Use MultiTrigger with multiple Conditions for combined checks","Always build Conditions fresh rather than reconfiguring"],"tags":["wpf","triggers","mutually-exclusive","invalid-operation"],"backgroundTag":"mutually-exclusive-options","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"}