How to add SVG images in .NET MAUI Button (SfButton)?
This article explains how to add SVG images in .NET MAUI Button, Which provides support to get an elegant view in your application by setting a background image and also displaying the button text along with the image.
Here, ImageSource property is used to set the icon in the button, which can be achieved by setting ShowIcon property to true. BackgroundImageSource property is used to set the background image to the Button.
.NET MAUI converts SVG files to PNG files. Therefore, adding an SVG file to your .NET MAUI app project should be referenced from XAML or C# with a .png extension.
Here, I added the image that shows the SVG-added images.
XAML:
<VerticalStackLayout Spacing="20" VerticalOptions="Center">
<buttons:SfButton Text="Home"
VerticalTextAlignment="End"
BackgroundImageSource="home.png"/>
<buttons:SfButton ShowIcon="True"
Text="Download"
ImageSource="download.png"/>
</VerticalStackLayout>
Output:
Conclusion:
I hope you enjoyed learning how to add SVG images in .NET MAUI Button (SfButton).
Refer to our .NET MAUI Button’s feature tour page for other groundbreaking feature representations. You can explore our .NET MAUI Button documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion, try our 30-day free trial to check out our .NET MAUI Button and other .NET MAUI components.
Please let us know in the following comments section if you have any queries or require clarifications. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!