Skip to content

[V12] Better support for CompiledBindings with a StaticResource as a source #21190

Description

@Adam-Wilkinson

Is your feature request related to a problem? Please describe.

I can't find any way to specify data type for compiled bindings when pointing the Source parameter at a static resource.

For example, the code snippet

TestProperty = {Binding PropertyOnResource, Source={StaticResource ExampleResourceKey}}

presents correctly in Rider, showing the correct type for the resource and property, but does not compile.

Describe the solution you'd like

Any syntax that gives does not give errors at design time or compile time. Ideally the syntax from the code sample would compile, but I understand it's possible for the type of the StaticResource to change, so the markup extension having a DataType parameter or listenning to the x:DataType attribute are also both good solutions.

Describe alternatives you've considered

In Rider, the following does not create design-time errors but also does not compile:

TestProperty = {Binding PropertyOnResource, x:DataType=ns:ResourceType, Source={StaticResource ExampleResourceKey}}

The following is a valid workaround, but creates design-time errors since DataType doesn't exist on CompiledBinding:

TestProperty = {Binding PropertyOnResource, DataType=ns:ResourceType, Source={StaticResource ExampleResourceKey}}

but does not work if you explicitly state it is a compiled binding; this fails to compile:

TestProperty = {CompiledBinding PropertyOnResource, DataType=ns:ResourceType, Source={StaticResource ExampleResourceKey}}

Is this is a hold over from how the {Binding} markup extension is handled internally?

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions