-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Comments
Will this still be part of .NET 9? I'm afraid a lot of people will run into this via #23711 if they are upgrading from .NET 9 |
@hansmbakker it's not likely this will be in .NET 9. It's true that the issue you linked shows that people might find it difficult to upgrade to .NET 9 in certain scenarios and we need to do something about it (most likely better warning messages). I don't think implementing the type inference the way I outlined it in this issue would fix that issue though. The problem there is that the |
Without this we'll not be able to compile app with .net9 as we need to use binding to Source{x:Reference |
@awasilik This should work: -<RowDefinition Height="{Binding HeightRequest, Source={x:Reference thisControl}}"/>
+<RowDefinition Height="{Binding HeightRequest, Source={x:Reference thisControl}, x:DataType={x:Null}}"/> However, yes, it requires manual changes in code. |
Because dotnet/maui#21834 isn't implemeted.
In certain scenarios, XamlC should be able to infer the
x:DataType
based on the value passed toBindingContext
on any XAML element or toSource
onBindingExtension
elements:{StaticResource X}
- in the case whenX
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 knownFindAncestor
FindAncestorBindingContext
- when the ancestor and the type of the binding context can be statically resolvedTemplatedParent
- when the templated parent can be statically resolvedExplicitly 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
The text was updated successfully, but these errors were encountered: