{"record":{"id":"e84a61d661473d39","repo":"dotnet/wpf","slug":"sr-unexpectedvaluetypeforcondition","errorCode":null,"errorMessage":"SR.UnexpectedValueTypeForCondition","messagePattern":"SR\\.UnexpectedValueTypeForCondition","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Condition.cs","lineNumber":211,"sourceCode":"                        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));\n            }\n\n            // Freeze the condition value\n            StyleHelper.SealIfSealable(_value);\n        }\n\n\n        #region ISupportInitialize Members\n\n        void ISupportInitialize.BeginInit()\n        {\n        }\n\n        void ISupportInitialize.EndInit()\n        {\n            // Resolve all properties here\n            if (_unresolvedProperty != null)\n            {","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Condition.cs#L193-L229","documentation":"Seal received a ValueLookupType it does not recognize; only Trigger, PropertyTriggerResource, DataTrigger and DataTriggerResource are valid. This is an internal invariant / unsupported enum value guard and throws InvalidOperationException.","triggerScenarios":"Passing an undefined or out-of-range ValueLookupType member to Condition.Seal, typically only reachable from internal style-sealing code or reflection.","commonSituations":"Framework-internal misuse or a custom framework subclass invoking Seal with an invented lookup type; virtually never hit by application developers.","solutions":["Pass only valid ValueLookupType members (Trigger, PropertyTriggerResource, DataTrigger, DataTriggerResource).","Let the style/trigger infrastructure call Seal itself rather than calling it manually.","If hit via reflection against a newer/older framework version, align code with the current enum members."],"exampleFix":"// before\ncondition.Seal((ValueLookupType)99);\n// after\ncondition.Seal(ValueLookupType.Trigger);","handlingStrategy":"type-guard","validationCode":"if (!Enum.IsDefined(typeof(ValueLookupType), type))\n    throw new ArgumentOutOfRangeException(nameof(type));","typeGuard":"bool IsKnownValueLookupType(ValueLookupType t) =>\n    t is ValueLookupType.Trigger or ValueLookupType.PropertyTriggerResource\n       or ValueLookupType.DataTrigger or ValueLookupType.DataTriggerResource;","tryCatchPattern":"try { condition.Seal(type); }\ncatch (InvalidOperationException ex) { /* pass a valid ValueLookupType */ }","preventionTips":["Only use documented ValueLookupType members.","Avoid calling internal Seal APIs directly; use the style/trigger infrastructure.","Re-check enum members when migrating framework versions."],"tags":["wpf","enum","internal"],"backgroundTag":"invalid-enum-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}