{"record":{"id":"726ade6fc895fd4c","repo":"dotnet/wpf","slug":"sr-format-sr-unexpectedvaluetypefordatatrigger-propertyvalue","errorCode":null,"errorMessage":"SR.Format(SR.UnexpectedValueTypeForDataTrigger, propertyValue.ValueType)","messagePattern":"SR\\.Format\\(SR\\.UnexpectedValueTypeForDataTrigger, propertyValue\\.ValueType\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/DataTrigger.cs","lineNumber":174,"sourceCode":"                    LogicalOp.Equals,\n                    _value) };\n\n            // Set Condition for all data triggers\n            for (int i = 0; i < PropertyValues.Count; i++)\n            {\n                PropertyValue propertyValue = PropertyValues[i];\n\n                propertyValue.Conditions = TriggerConditions;\n                switch (propertyValue.ValueType)\n                {\n                    case PropertyValueType.Trigger:\n                        propertyValue.ValueType = PropertyValueType.DataTrigger;\n                        break;\n                    case PropertyValueType.PropertyTriggerResource:\n                        propertyValue.ValueType = PropertyValueType.DataTriggerResource;\n                        break;\n                    default:\n                        throw new InvalidOperationException(SR.Format(SR.UnexpectedValueTypeForDataTrigger, propertyValue.ValueType));\n                }\n\n                // Put back modified struct\n                PropertyValues[i] = propertyValue;\n            }\n\n            base.Seal();\n        }\n\n        // evaluate the current state of the trigger\n        internal override bool GetCurrentState(DependencyObject container, UncommonField<HybridDictionary[]> dataField)\n        {\n            Debug.Assert( TriggerConditions != null && TriggerConditions.Length == 1,\n                \"This method assumes there is exactly one TriggerCondition.\" );\n\n            return TriggerConditions[0].ConvertAndMatch(StyleHelper.GetDataTriggerValue(dataField, container, TriggerConditions[0].Binding));\n        }\n","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/DataTrigger.cs#L156-L192","documentation":"DataTrigger.Seal throws InvalidOperationException when it encounters a PropertyValueType in its property values it does not recognize while converting to the DataTrigger form. This is an internal invariant check — only PropertyTrigger and PropertyTriggerResource are legal here. Hitting it means internal property-engine state was corrupted or a new value type was added without updating DataTrigger.","triggerScenarios":"Internal sealing pipeline encountering an unexpected PropertyValueType enum value in PropertyValues; usually not reachable from public API without framework-internal misuse.","commonSituations":"Running modified/reflected internal WPF code; third-party libraries poking at internal property-engine structures; WPF version mismatches.","solutions":["Check that property values were only created through the public style/trigger APIs","Review PropertyValueType values produced upstream (StyleHelper / property engine) for a case missing from DataTrigger.Seal","Report as a WPF framework bug if reproduced with public API only"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { trigger.Seal(); } catch (InvalidOperationException ex) { Debug.Fail($\"Internal PropertyValueType corruption: {ex.Message}\"); }","preventionTips":["Create triggers/styles only through public APIs","Do not reflect into internal WPF property-engine structures","Keep WPF assembly versions consistent across the app"],"tags":["wpf","datatrigger","internal-invariant","property-engine"],"backgroundTag":"internal-invariant-violation","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"}