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

SvgImage: How to specify SvgAssembly or SvgAssemblyType in XAML #33

Open
opcodewriter opened this issue Aug 5, 2016 · 3 comments
Open

Comments

@opcodewriter
Copy link

What's the cleanest way?
I wish that these properties had a type converter to allow that.

@opcodewriter
Copy link
Author

opcodewriter commented Aug 5, 2016

Weird thing that this doesn't work (SVG is not displayed):
SvgAssemblyType="{x:Type vm:MyViewModel}"

Doing the same thing by code works.

@opcodewriter
Copy link
Author

I spent an incredibly amount of time on this...
Maybe this is helpful for someone else too.

The issue with not updating when using in XAML is because in the propertyChanged callback, it calls ctrl.SvgAssemblyType = (Type)newValue; but in the getter the getter value is already the same with property, therefore UpdateSvg and Invalidate are not called.
An easy fix is to explicitly call UpdateSvg and Invalidate on each propertyChanged.

But the real issue I think is that by default the SvgImage should use the current assembly, such that there shouldn't be necessary to set it explicitly.

        public static BindableProperty SvgAssemblyTypeProperty =
            BindableProperty.Create(nameof(SvgAssemblyType), typeof(Type), typeof(SvgImage), Application.Current.GetType(),
                propertyChanged: (bindable, oldValue, newValue) => {
                    var ctrl = (SvgImage)bindable;
                    ctrl.SvgAssemblyType = (Type)newValue;
                });

Another thing: I don't understand why all the 3 bindable properties are two-way, it doesn't make sense
to me, the control doesn't change any of them.

@chrfalch
Copy link
Owner

You are welcome to fork the project and try to if you can fix this and submit a pull request if possible.

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