{"record":{"id":"6dffa12c1020ee18","repo":"dotnet/wpf","slug":"sr-format-sr-parsercannotconvertpropertyvalue-value-typeof","errorCode":null,"errorMessage":"SR.Format(SR.ParserCannotConvertPropertyValue, \"Value\", typeof(Object).FullName)","messagePattern":"SR\\.Format\\(SR\\.ParserCannotConvertPropertyValue, \"Value\", typeof\\(Object\\)\\.FullName\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/SetterTriggerConditionValueConverter.cs","lineNumber":97,"sourceCode":"        #endregion Public Methods\n\n        internal static object ResolveValue(ITypeDescriptorContext serviceProvider,\n            DependencyProperty property, CultureInfo culture, object source)\n        {\n            ArgumentNullException.ThrowIfNull(serviceProvider);\n            ArgumentNullException.ThrowIfNull(source);\n\n            // Only need to type convert strings and byte[]\n            if (!(source is byte[] || source is String || source is Stream))\n            {\n                return source;\n            }\n\n            IXamlSchemaContextProvider ixsc = (serviceProvider.GetService(typeof(IXamlSchemaContextProvider))\n                as IXamlSchemaContextProvider);\n            if (ixsc == null)\n            {\n                throw new NotSupportedException(SR.Format(SR.ParserCannotConvertPropertyValue, \"Value\", typeof(Object).FullName));\n            }\n            XamlSchemaContext schemaContext = ixsc.SchemaContext;\n\n            if (property != null)\n            {\n                //Get XamlMember from dp\n                System.Xaml.XamlMember xamlProperty = \n                    schemaContext.GetXamlType(property.OwnerType).GetMember(property.Name);\n                if (xamlProperty == null)\n                    xamlProperty = \n                        schemaContext.GetXamlType(property.OwnerType).GetAttachableMember(property.Name);\n\n                System.Xaml.Schema.XamlValueConverter<TypeConverter> typeConverter = null;\n                \n                if (xamlProperty != null)\n                { \n                    // If we have a Baml2006SchemaContext and the property is of type Enum, we already know that the \n                    // type converter must be the EnumConverter.","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/SetterTriggerConditionValueConverter.cs#L79-L115","documentation":"SetterTriggerConditionValueConverter.ResolveValue needs IXamlSchemaContextProvider from the service provider to convert the 'Value' string of a Setter/Trigger/Condition. If the schema context service is absent, the converter cannot operate, so it throws NotSupportedException indicating it cannot convert the Value property to Object.","triggerScenarios":"Using SetterTriggerConditionValueConverter (the Value of Setter/Trigger/Condition properties) outside of a proper XAML schema context, e.g. calling TypeConverter.ConvertFromString with a bare or incomplete ITypeDescriptorContext/IServiceProvider that doesn't supply IXamlSchemaContextProvider.","commonSituations":"Invoking the converter directly at runtime without going through the XAML parser; custom tooling that fakes the service provider; parsing Styles with a non-WPF XAML reader lacking schema-context services.","solutions":["Ensure conversion happens within the standard WPF XAML load pipeline which supplies IXamlSchemaContextProvider","If calling manually, provide an IServiceProvider that implements GetService(typeof(IXamlSchemaContextProvider))","Use a different conversion mechanism (e.g. TypeDescriptor.GetConverter) when not under XAML parse"],"exampleFix":"// before\nvar converter = new SetterTriggerConditionValueConverter();\nvar value = converter.ConvertFromString(null); // no schema context service\n// after\n// let the XAML parser perform the conversion, or supply a proper service provider\nvar value = (string)xamlSchemaContextClrValue; // convert via schema context when hand-rolling","handlingStrategy":"try-catch","validationCode":"var sc = serviceProvider.GetService(typeof(IXamlSchemaContextProvider)) as IXamlSchemaContextProvider;\nif (sc == null) throw new InvalidOperationException(\"Setter/Trigger conversion requires a XAML schema context\");","typeGuard":"bool HasSchemaContext(IServiceProvider sp) => sp?.GetService(typeof(IXamlSchemaContextProvider)) is IXamlSchemaContextProvider;","tryCatchPattern":"try { value = converter.ConvertFromString(serviceProvider, valueString); }\ncatch (NotSupportedException ex) { /* conversion attempted outside XAML parse; use parser or proper service provider */ }","preventionTips":["Let the WPF XAML parser perform Setter/Trigger Value conversions","Do not call SetterTriggerConditionValueConverter directly with minimal service providers","Provide IXamlSchemaContextProvider when hand-rolling XAML tooling"],"tags":["wpf","xaml","converter","not-supported"],"backgroundTag":"missing-dependency","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"}