You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think XamlC should produce a warning when there is a {Binding ...} inside of a DataTemplate which inherits x:DataType from outside of the template. Consider the following example:
The Text property will contain a TypedBinding<PageViewModel, PageViewModel> and when the item will have a different type, the label will be empty without producing any warning ([X] do not apply Bindings if DataType doesnt match #22056)
My suggestion is to report a warning something like
XC0024: Binding might be compiled incorrectly because it is using an x:DataType local:PageViewModel that is defined outside of the current DataTemplate scope. Consider adding x:DataType directly to the DataTemplate. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information.
... and add a paragraph describing this issue to the linked documentation page.
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
FWIW:
Another idea for the warning message could be that our recommendation is to always specify x:DataType for bindings in templates explicitly, as if it is omitted it could inherit x:DataType from a parent scope and cause runtime failures.
I think XamlC should produce a warning when there is a
{Binding ...}
inside of aDataTemplate
which inheritsx:DataType
from outside of the template. Consider the following example:Text
property will contain aTypedBinding<PageViewModel, PageViewModel>
and when the item will have a different type, the label will be empty without producing any warning ([X] do not apply Bindings if DataType doesnt match #22056)My suggestion is to report a warning something like
... and add a paragraph describing this issue to the linked documentation page.
Related to #22056
/cc @StephaneDelcroix @ivanpovazan @PureWeen @mattleibow
The text was updated successfully, but these errors were encountered: