Hello,
Welcome to Microsoft Q&A!
You couldn't use the svg file in xaml Path.Data . You could refer to the thread: https://github.com/microsoft/microsoft-ui-xaml/issues/507
You need to create a SvgImageSource object
with your own SVG string, and then set the SvgImageSource object
to the source of the image.
You could follow the following code:
var svg = new SvgImageSource();
string SampleSvg = "your SVG string";
using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(SampleSvg)))
{
stream.Seek(0, SeekOrigin.Begin);
SvgImageSource imageSource = new SvgImageSource();
imageSource.RasterizePixelWidth = yourWidth;
imageSource.RasterizePixelHeight = yourHeight;
imageSource.SetSourceAsync(stream.AsRandomAccessStream()).AsTask();
MyImageName.Source = imageSource;
}
<Grid Background="Black">
<Image x:Name="MyImageName" Height="200" Width="200"/>
</Grid>
Thank you.
Jeanine
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.