Xamarin.Forms - How to use SvgImageSource with Button ?
See original GitHub issueHi, Perhaps I’m missing something obivous, but I just couldn’t find a way to use SvgImageSource as ImageSource for Button. I’ve managed to use it for ImageButton using the examples provided, but ImageButton doesn’t support Visual Material yet and behaves differently.
Ideally, I would like to do something like the following. Is it possible ?
<Button Padding="20"
BackgroundColor="Blue"
CornerRadius="25"
HeightRequest="50"
WidthRequest="50">
<Button.ImageSource>
<ffimagesvg:SvgImageSource Source="resource://022-oil-gauge.svg"/>
</Button.ImageSource>
</Button>
I’m using VS 2019 16.7.0 Pro, latest Xamarin.Forms, FFImageLoading and targeting API Level 29.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top Results From Across the Web
How to add the SVG images in Xamarin.Forms button
This article explains about how to use svg images for Xamarin.Forms button. ... Xamarin.Forms.Svg provides SvgImageSource to add Xamarin.Forms ImageSource.
Read more >Xamarin.Forms set Button ImageSource as ffimageloading ...
Usage : Use SvgCachedImage to show the embedded svg image and use TapGestureRecognizer to simulate the button click event. <ffimageloadingsvg: ...
Read more >Displaying SVGs in Xamarin.Forms - Damir's Corner
Forms.Svg NuGet package. I created a value converter that generates the correct image source for each image type: SvgImageSource from this NuGet ...
Read more >Xamarin.Forms ImageButton
The ImageButton displays an image and responds to a tap or click that directs an application to carry out a particular task.
Read more >Xamarin.Forms - How to use SvgImageSource with Button
Hi, Perhaps I'm missing something obivous, but I just couldn't find a way to use SvgImageSource as ImageSource for Button.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@timvandenhof Sorry, I haven’t been able to find a solution to this. But I’ve achieved what I wanted in a different way.
I’m using Visual Material. Not all visual elements support it yet. I especially like the visual feedback it gives.
Currently I’m using @AndreiMisiukevich 's TouchEffect library TouchEffect to add that effect to almost anything. For example it provides a nice way to catch taps on items in a CollectionView with visual feedback, I highly recommend it. It supports Android, iOS, Mac and UWP, but I only used it on Android yet.
If you also like a nice drop shadow for your visual elements check out Sharpnado.Shadows by @roubachof
There is also a trick with Visual Studio. When you add an embedded resource to the NET Standard project, it doesn’t automatically give a logical name to the resource, which forces you to use the whole path. I do the following in the NET Standard project file.
The following provides me with a nice circular button with an embedded SVG and I can also add a label to it very easly if necessary. If not, just remove the StackLayout.
@timvandenhof i’ve decided to use resizetizerNT to load up all my svg’s - get them transformed to regular pngs and then use the images as usual in xamarin forms. Maybe this solution will fulfill your needs