maui
maui copied to clipboard
SVG extension Image does not work on ImageButton/Button
Description
When I created a ImageButton or Button, set Source/ImageSource property with a svg extension like below:
<Button ImageSource="button.svg"/>
The button would show nothing. But it works on MacOS
Steps to Reproduce
- Create a maui project
- Add ImageButton or Button
- Set Source or ImageSource with a svg extension image
Version with bug
Release Candidate 2
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Windows 10
Did you find any workaround?
No response
Relevant log output
No response
Have you tried using PNG extension? As far as I know all svg images are converted to static images with fixed size on build anyway.
As pointed out, did you try the png extension? Does that resolve the issue (for now)?
Hi @AllenMiaoFil. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
As pointed out, did you try the png extension? Does that resolve the issue (for now)?
@jfversluis Yes, I've tested with png, it works, only SVG on windows does not work. Actually we want to use svg opacity. PNG is converted. it can't resolve issue
we want to use svg opacity
I am not sure what you mean by this? When the svg is converted to a png, the values in the svg are used on a transparent image.
Also, the svg is just a build input and never reaches the final app.
@mattleibow I see, I just want to modify some properties of SVG based on different State in VSM, Not sure I can do that or not, for right now we use PNG instead SVG in windows as a work around and I modified button's Opacity, It would affect full button color. And another issue is SVG works on MacOS, but does not work on Windows. Let me know If it is a issue? otherwise I will close this issue. Thanks
I can confirm svg works on Windows in GA using it as ".png"
@AllenMiaoFil would you mind opening a new feature request for adding an ImageOpacity property to ImageButton?
https://github.com/dotnet/maui/issues/new?assignees=&labels=proposal%2Fopen%2Ct%2Fenhancement&template=feature-request.yml
https://github.com/dotnet/maui/issues/7597 link is the new feature for adding Opacity to ImageButton and Button.
@AllenMiaoFil So can this issue be closed? track with https://github.com/dotnet/maui/issues/7597?
Hi @AllenMiaoFil. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
Hey @kristinx0211, I don't think they are same issue, https://github.com/dotnet/maui/issues/7597 is about button-opacity, And This is about SVG as a Source doesn't work on Button/Image Button, but it is working on Mac.
I hit the same issue. I had to remove the .svg extension to make it work.
Just trying to recap the OP issue here...
The issue is that using myimage.svg does not work - even though you added that to your project. But, if you use myimage.png it does - and this is unexpected (and potentially confusing if you do not know the secrets of the inner workings of the build process).
Unless we are all missing something?
Closing this in favor of: https://github.com/dotnet/maui/issues/13368
We should create some kind of code analyzer that warns against the usage of button.svg. Upvote if this is important to you, thanks!
Duplicate of #13368