dotnet/wpf · error

SR.Format(SR.ParserCannotConvertPropertyValue, "Property"…

Error message

SR.Format(SR.ParserCannotConvertPropertyValue, "Property", typeof(DependencyProperty).FullName)

What it means

DependencyPropertyConverter.ResolveProperty parses a string like 'OwnerType.Property' into a DependencyProperty. The else-branch throws NotSupportedException when the value has no recognized separator form — i.e. the string is neither owner-qualified nor resolvable through the parsing path, so no 'Property' portion could be extracted.

Solutions

  1. Qualify the property with its owner type: Property="Control.Background"
  2. Use the x:Static or attached-property syntax appropriate for the property
  3. Check for typos such as a missing '.' between type and property name
  4. If the type must come from TargetName/sourceName, ensure the template context provides it

Example fix

// before
<Setter Property="Background" Value="Red"/>// after
<Setter Property="Control.Background" Value="Red"/>
Defensive patterns

Strategy: validation

Validate before calling

static bool IsQualifiedProperty(string v) => v != null && v.Contains('.');
if (!IsQualifiedProperty(propertyString)) throw new ArgumentException("Use 'Type.Property' form for Setter/Trigger Property");

Type guard

static bool IsValidDpString(string? v) => !string.IsNullOrEmpty(v) && v.Split('.').Length == 2;

Try / catch

try { var dp = (DependencyProperty)converter.ConvertFrom(ctx, culture, value); } catch (NotSupportedException ex) when (ex.Message.Contains("DependencyProperty")) { throw new XamlParseException($"Property '{value}' must be owner-qualified, e.g. 'Control.{value}'"); }

Prevention

When it happens

Trigger: Setter Property or Trigger Property value given as a bare or malformed string that lacks the expected 'Type.Property' / 'prefix:Type.Property' format, so the value does not contain a parsable property reference.

Common situations: XAML like <Setter Property="Background"/> where the value lacks a type qualifier and no owning type can be determined; copy-pasted WPF property strings into a context expecting qualified names; typos dropping the '.Property' part.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/9cbaeae6c620e91c. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/DependencyPropertyConverter.cs:156

                    int lastIndex = value.LastIndexOf('.');
                    string typeName = value.Substring(0, lastIndex);
                    property = value.Substring(lastIndex + 1);

                    IXamlTypeResolver resolver = serviceProvider.GetService(typeof(IXamlTypeResolver))
                        as IXamlTypeResolver;
                    type = resolver.Resolve(typeName);
                }
                else
                {
                    // Only have the property name
                    // Strip prefixes if there are any, v3 essentially discards the prefix in this case
                    int lastIndex = value.LastIndexOf(':');
                    property = value.Substring(lastIndex + 1);
                }
            }
            else
            {
                throw new NotSupportedException(SR.Format(SR.ParserCannotConvertPropertyValue, "Property", typeof(DependencyProperty).FullName));
            }

            // We got additional info from either Trigger.SourceName or Setter.TargetName
            if (type == null && targetName != null)
            {
                IAmbientProvider ambientProvider = serviceProvider.GetService(typeof(IAmbientProvider))
                    as System.Xaml.IAmbientProvider;
                XamlSchemaContext schemaContext = (serviceProvider.GetService(typeof(IXamlSchemaContextProvider))
                    as IXamlSchemaContextProvider).SchemaContext;

                type = GetTypeFromName(schemaContext,
                    ambientProvider, targetName);
            }

            // Still don't have a Type so we need to loop up the chain and grab either Style.TargetType,
            // DataTemplate.DataType, or ControlTemplate.TargetType
            if (type == null)
            {

View on GitHub (pinned to 81131a70a4)