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

Fix ICommand bindings in style setters #16122

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

grokys
Copy link
Member

@grokys grokys commented Jun 25, 2024

What does the pull request do?

As described in #16113, when compiling a binding to e.g. Button.Command in a style Setter, we were not converting XamlIlClrMethodPathElementNode to XamlIlClrMethodAsCommandPathElementNode as we were only testing whether the property that the binding was being assigned to is an ICommand: in this case Setter.Value is an object so the conversion wasn't happening.

If we detect that we're assigning the binding to a Setter.Value then we need to look in the Setter.Property to see check whether the property is an ICommand too.

Fixed issues

Fixes #16113

When compiling a binding to e.g. `Button.Command` in a style `Setter`, we were not converting `XamlIlClrMethodPathElementNode` to `XamlIlClrMethodAsCommandPathElementNode` as we were only testing whether the property that the binding was being assigned to is an `ICommand`.

If we detect that we're assigning the binding to a `Setter.Value` then we need to look in the `Setter.Property` to see check whether the property is an `ICommand` too.

Fixes #16113
@grokys grokys requested review from kekekeks and maxkatz6 June 25, 2024 13:58
@grokys grokys changed the title Fix ICommand bindings in styles Fix ICommand bindings in styles Jun 25, 2024
@grokys grokys changed the title Fix ICommand bindings in styles Fix ICommand bindings in style setters Jun 25, 2024
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0049317-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 merged commit 0b5adbd into master Jun 26, 2024
10 of 12 checks passed
@maxkatz6 maxkatz6 deleted the fixes/16113-command-binding-in-style branch June 26, 2024 02:49
grokys added a commit that referenced this pull request Jun 28, 2024
* Add failing test for #16113.

* Convert delegate to ICommand in style setter.

When compiling a binding to e.g. `Button.Command` in a style `Setter`, we were not converting `XamlIlClrMethodPathElementNode` to `XamlIlClrMethodAsCommandPathElementNode` as we were only testing whether the property that the binding was being assigned to is an `ICommand`.

If we detect that we're assigning the binding to a `Setter.Value` then we need to look in the `Setter.Property` to see check whether the property is an `ICommand` too.

Fixes #16113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DefaultValueConverter does not work within styles
3 participants