Skip to content

Binding with Converter and x:DataType is not compiled — falls back to runtime and throws missing resource #34713

@StephaneDelcroix

Description

@StephaneDelcroix

Description

When a Binding has both a Converter={StaticResource ...} and is inside a scope with x:DataType, the binding is not compiled (i.e., no TypedBinding is generated). Instead, it falls back to a runtime-interpreted binding.

At runtime, the interpreted binding tries to resolve the StaticResource converter through the standard resource lookup path, which can fail — resulting in a missing resource exception.

Expected Behavior

The binding should be compiled into a TypedBinding (just like bindings without converters), with the converter resolved at runtime via this.Resources["key"].

Actual Behavior

The binding falls back to runtime interpretation and throws:

Resource not found: "SomeConverter"

Steps to Reproduce

  1. Create a page with x:DataType set on a parent element
  2. Add a Label with Text="{Binding SomeProperty, Converter={StaticResource SomeConverter}}"
  3. Ensure SomeConverter is not present in the page Resources
  4. Build and run — the app crashes

Context

This is a BindingSourceGen limitation — the source generator likely skips bindings with converters because it cannot statically resolve the converter type from a StaticResource reference.

Affected Area

  • BindingSourceGen (compiled bindings with converters)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-xamlXAML, CSS, Triggers, Behaviorss/triagedIssue has been reviewedxsgXaml sourceGen

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions