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

[X] do not apply Bindings if DataType doesnt match #22056

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

StephaneDelcroix
Copy link
Contributor

@StephaneDelcroix StephaneDelcroix commented Apr 25, 2024

src/Controls/src/Core/Binding.cs Show resolved Hide resolved
var bindingContext = src ?? Context ?? context;
if (DataType != null && bindingContext != null && !DataType.IsAssignableFrom(bindingContext.GetType()))
{
bindingContext = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we log a warning to make it easier to debug the type mismatch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid that a warning will make HotReload fail

src/Controls/src/Xaml/MarkupExtensions/BindingExtension.cs Outdated Show resolved Hide resolved
Comment on lines +31 to +32
if (node is IElementNode elementNode)
Add(typeof(IXamlDataTypeProvider), new XamlDataTypeProvider(elementNode));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this service be added even when XamlC creates the new XamlServiceProvider instance? And if it is, won't this be added for almost any extension, even if IXamlDataTypeProvider is not in its [RequiredService([...])]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going to fix this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RequiredService isn't in main yet. also, this won't get invoked from compiled XAML

Make sure the behavior of bindings is consistent accross implementations
(compiled/not compiled)

fixes a bunch of issues
@StephaneDelcroix StephaneDelcroix enabled auto-merge (squash) May 17, 2024 10:03
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
3 participants