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

Can't bind to Uri-path for Source property #7717

Open
duck-dev opened this issue Feb 26, 2022 · 4 comments
Open

Can't bind to Uri-path for Source property #7717

duck-dev opened this issue Feb 26, 2022 · 4 comments

Comments

@duck-dev
Copy link

Describe the bug
I can't bind to a property of type Uri (not even Uri?) for the Source property of a StyleInclude in this case. I get faced with this error upon building the application:

[XAMLIL] Unable to find suitable setter or adder for property Source of type Avalonia.Markup.Xaml:Avalonia.Markup.Xaml.Styling.StyleInclude for argument Avalonia.Markup:Avalonia.Data.Binding, available setter parameter lists are:
System.Uri Line 16, position 23.

I hope I'm not missing something too obvious, which is not unlikely to happen, considering my current state of concentration due to specific reasons, but I'm pretty sure this looks plausible. I'm not able to see where the issue lies.

The reason why I'm opening an issue for this, is that it might not look like expected behaviour at once and is possible to be an internal issue. It would also automatically be a proposal for a "feature" if it's not intended to bind for Uri sources.
I thoroughly searched through previous issues and the internet in general, which didn't help me much.

To Reproduce
App.axaml:

<Application.Styles>
    <StyleInclude Source="{Binding SomeSource}"/>
</Application.Styles>

App.axaml.cs:

private Uri SomeSource // Same thing with nullable type (Uri?)
{
    get => _someSource; 
    set => this.SetAndRaise(_someSourceProperty, ref _someSource, value);
}

Expected behavior
It should bind correctly and not throw this error.

Desktop (please complete the following information)

  • OS: Linux (Pop! OS 21.10)
  • Version: Avalonia 0.10.11
@duck-dev duck-dev added the bug label Feb 26, 2022
@maxkatz6 maxkatz6 removed the bug label Feb 26, 2022
@maxkatz6
Copy link
Member

Source binding isn't supported, just like it isn't in wpf/uwp.

@duck-dev
Copy link
Author

@maxkatz6 Thank you very much for your answer!

That's what I supposed. Is there a specific reason for that, which is not necessarily bound to difficulties in implementation or is exactly that the reason, which I doubt if it isn't supported in WPF and UWP either?

And while we're at it, what would you propose as a better way to have a path that may change at runtime? A dynamic resource for example?

@maxkatz6
Copy link
Member

maxkatz6 commented Feb 26, 2022

And while we're at it, what would you propose as a better way to have a path that may change at runtime? A dynamic resource for example?

Simply remove this and add new StyleInclude from the styles collection. It will work.

@duck-dev
Copy link
Author

Oh yes, that definitely makes sense. Just removing this entry from Application.Styles and adding a new one is very acceptable.

Thank you a lot!

@duck-dev duck-dev reopened this Feb 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants