Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XC] Infer x:DataType from BindingContext or BindingExtension.Source #21834

Open
9 tasks
simonrozsival opened this issue Apr 15, 2024 · 0 comments
Open
9 tasks
Labels
area-xaml XAML, CSS, Triggers, Behaviors

Comments

@simonrozsival
Copy link
Member

simonrozsival commented Apr 15, 2024

In certain scenarios, XamlC should be able to infer the x:DataType based on the value passed to BindingContext on any XAML element or to Source on BindingExtension elements:

  • {StaticResource X} - in the case when X is defined in the same XAML document
  • {x:Static Y}
  • {x:Reference Z}
  • {Binding W} - when the binding is compiled
  • {Binding Source={RelativeSource U}}:
    • Self - when the elemet to which the binding is set is statically known
    • FindAncestor
    • FindAncestorBindingContext - when the ancestor and the type of the binding context can be statically resolved
    • TemplatedParent - when the templated parent can be statically resolved

Explicitly declared x:DataType should always take precedence over the inferred type. In the case when there is a mismatch, we should consider emitting a warning.

Are there any other cases which we could infer?

/cc @StephaneDelcroix

@dotnet-policy-service dotnet-policy-service bot added the s/triaged Issue has been reviewed label Apr 15, 2024
@simonrozsival simonrozsival added area-xaml XAML, CSS, Triggers, Behaviors and removed s/triaged Issue has been reviewed labels Apr 15, 2024
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Apr 15, 2024
@PureWeen PureWeen modified the milestones: Backlog, .NET 9 Planning May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors
Projects
None yet
Development

No branches or pull requests

3 participants