maui icon indicating copy to clipboard operation
maui copied to clipboard

SVG extension Image does not work on ImageButton/Button

Open AllenMiaoFil opened this issue 3 years ago • 15 comments

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

  1. Create a maui project
  2. Add ImageButton or Button
  3. 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

AllenMiaoFil avatar May 12 '22 06:05 AllenMiaoFil

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.

Symbai avatar May 12 '22 08:05 Symbai

As pointed out, did you try the png extension? Does that resolve the issue (for now)?

jfversluis avatar May 12 '22 09:05 jfversluis

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.

ghost avatar May 12 '22 09:05 ghost

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

AllenMiaoFil avatar May 12 '22 09:05 AllenMiaoFil

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 avatar May 14 '22 04:05 mattleibow

@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

AllenMiaoFil avatar May 16 '22 01:05 AllenMiaoFil

I can confirm svg works on Windows in GA using it as ".png"

DeanFaizal avatar May 27 '22 12:05 DeanFaizal

@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

DeanFaizal avatar May 27 '22 12:05 DeanFaizal

https://github.com/dotnet/maui/issues/7597 link is the new feature for adding Opacity to ImageButton and Button.

AllenMiaoFil avatar May 30 '22 00:05 AllenMiaoFil

@AllenMiaoFil So can this issue be closed? track with https://github.com/dotnet/maui/issues/7597?

kristinx0211 avatar Jun 21 '22 08:06 kristinx0211

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.

ghost avatar Jun 21 '22 08:06 ghost

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.

ghost avatar Jun 27 '22 00:06 ghost

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.

AllenMiaoFil avatar Jun 27 '22 02:06 AllenMiaoFil

I hit the same issue. I had to remove the .svg extension to make it work.

richardlalancetteyoui avatar Aug 29 '22 20:08 richardlalancetteyoui

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?

mattleibow avatar Nov 10 '22 20:11 mattleibow

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!

jonathanpeppers avatar Feb 21 '23 15:02 jonathanpeppers

Duplicate of #13368

samhouts avatar Mar 02 '23 01:03 samhouts