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

StyledProperty Binding with Converter #2161

Closed
pr8x opened this issue Dec 4, 2018 · 5 comments
Closed

StyledProperty Binding with Converter #2161

pr8x opened this issue Dec 4, 2018 · 5 comments
Assignees
Labels

Comments

@pr8x
Copy link
Contributor

pr8x commented Dec 4, 2018

    <seqc:MarkerControl Margin="205 0 0 20" 
                        MarkerOffset="{Binding RelativeMarkerOffset, Converter={StaticResource TrackCoordsConverter}}"/>

MarkerOffset is declared as:

 public static readonly StyledProperty<int> MarkerOffsetProperty
            = AvaloniaProperty.Register<MarkerControl, int>(nameof(MarkerOffset));

        public int MarkerOffset
        {
            get => GetValue(MarkerOffsetProperty);
            set => SetValue(MarkerOffsetProperty, value);
        }

Unfortunately, it keeps binding to zero, even if the correct value (515) is displayed in the avalonia debugger. Binding without a Converter and binding to Width works just fine. What am I missing out?

@donandren
Copy link
Contributor

@toytonics if you use something like:

{Binding RelativeMarkerOffset, Converter={x:Static MyConverters.TrackCoordsConverter}}

where MyConverters.TrackCoordsConverter is static property
is it crashing or working?

@pr8x
Copy link
Contributor Author

pr8x commented Dec 10, 2018

Hi, haven't tried your suggestion yet. But I think it's pretty weird that the correct value is displayed in the debugger, but is not used as the final value...

image

What does the * mean here? How do I force it to use the bound value (61,5)?

Edit: Nope, Using x:Static does not solve the issue

@grokys
Copy link
Member

grokys commented Dec 10, 2018

Hmm, that is strange. As you say it looks like the binding is producing the correct value, but that's somehow not reflected in the property value. Would you be able to create a minimal repro in a repository or something for me to debug?

@pr8x
Copy link
Contributor Author

pr8x commented Dec 11, 2018

https://github.com/toytonics/Avalonia_Bug_StyledProperty

Should reproduce this bug.

@ahopper
Copy link
Contributor

ahopper commented Dec 11, 2018

@toytonics if you convert to a string in your converter it then works here.

@grokys grokys added the bug label Feb 22, 2019
@grokys grokys self-assigned this Feb 22, 2019
@pr8x pr8x closed this as completed Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants