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

Unable to find suitable setter or adder for property Converter of type #2

Closed
racerxdl opened this issue Feb 23, 2024 · 4 comments
Closed

Comments

@racerxdl
Copy link

Unable to find suitable setter or adder for property Converter of type Avalonia.Markup.Xaml:Avalonia.Markup.Xaml.MarkupExtensions.ReflectionBindingExtension for argument Avalonia.Base:Avalonia.Data.IBinding, available setter parameter lists are:
Avalonia.Data.Converters.IValueConverter Line 91, position 92.

This happens when there is a custom converter for any field, for example, as described here: https://docs.avaloniaui.net/docs/guides/data-binding/how-to-create-a-custom-data-binding-converter

@Kir-Antipov
Copy link
Owner

That's interesting. Will look into that.

@racerxdl
Copy link
Author

Just for more context: This happens because you change all StaticResources to Dynamic (see https://github.com/Kir-Antipov/HotAvalonia/blob/master/src/HotAvalonia/Helpers/AvaloniaControlHelper.cs#L176-L181 ) but resources that are declared in the same axaml file (or from included axaml files) should be kept static.

I just made a quick hack for my scenario, changing to:

return xaml.Replace(staticResourceName, dynamicResourceName).Replace("Converter={Dynamic", "Converter={Static");

Fixes it, although its not exactly the right solution.

@Kir-Antipov
Copy link
Owner

Thanks a lot for your help in identifying the problem! It means a lot and also significantly simplifies things on my side too :)

I'm glad this ended up being my screw-up and not a limitation on Avalonia.Markup.Xaml.Loader's side, as I have no control over it. To be quite frankly honest with you, I guess I brainfarted when I wrote that code, as I never intended to replace nested static resources with dynamic ones, as those usually have stricter resolution rules, like in your case with converters.

Fixes it, although its not exactly the right solution.

Well, the issue it fixes stems from the code that's not intended to be good or even right either, as it's just a quick fixup to allow static resources to be hot reloaded. Sometimes a good enough solution is all you need ;)


Also, I do apologize for the delay on my side in dealing with this matter, but I'm currently a bit overwhelmed. I hope to address the accumulated backlog next week when I have more time.

@racerxdl
Copy link
Author

Don't worry, I also have so many stuff to do that I couldn't investigate any further to see what else could be done. Still, thanks for the attention and fix ^^

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

No branches or pull requests

2 participants