-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Handle $self in compiled binding in multibinding. #14935
Conversation
You can test this PR using the following package version. |
@@ -123,7 +123,12 @@ IEnumerable<XamlPropertyAssignmentNode> getResourceValues(IXamlAstNode node) | |||
}; | |||
|
|||
var selfType = context.ParentNodes().OfType<XamlAstConstructableObjectNode>().First().Type.GetClrType(); | |||
|
|||
|
|||
if (context.GetAvaloniaTypes().MultiBinding.IsAssignableFrom(selfType)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be a loop to handle nested MultiBinding
s.
(Granted, it's probably a rare case, but they work in reflection mode.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see as much problem with nested MultiBinding, but more with other markup extensions in general.
Like, Binding inside of OnPlatform extension. Which wouldn't be as rare use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More generic fix can be added later though. Just to keep in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OnPlatform
/OnFormFactor
both already work with this PR, because they're transformed into special nodes which aren't XamlAstConstructableObjectNode
. I couldn't find any other case that the nested MultiBinding
one, which is easy to handle. If there are others I'm missing, we can indeed add a more general solution later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, other would be MarkupExtension implementations that don't have special transformer support from the compiler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think nested MultiBindings could be handled by doing this?
var selfType = context.ParentNodes().OfType<XamlAstConstructableObjectNode>()
.Select(n => n.Type.GetClrType())
.Where(t => !context.GetAvaloniaTypes().MultiBinding.IsAssignableFrom(t))
.First();
Thank you! |
What does the pull request do?
Enables compiled bindings in multibindings.
What is the current behavior?
Compilation error:
Avalonia error AVLN:0004: Unable to resolve property or method of name 'FontStyle' on type 'Avalonia.Data.MultiBinding'.
What is the updated/expected behavior with this PR?
That the bindings work the same as when using reflection bindings.
How was the solution implemented (if it's not obvious)?
Tried to do something similar as to how the type is resolved in a style setter.
Fixed issues
Fixes #13528