Hello,
Welcome to our Microsoft Q&A platform!
SVG is a XML format, you can iterate through a SVG file the same as with any XML file. I define a circle SVG and iterate it with XML file like following code:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<circle cx="100" cy="50" r="40" stroke="black"
stroke-width="2" fill="red" />
</svg>
var assembly = GetType().GetTypeInfo().Assembly;
Stream stream = assembly.GetManifestResourceStream("XMLFile.xml");
XmlDocument xml = new XmlDocument();
xml.Load(stream);
var circle = xml.GetElementsByTagName("circle").Item(0).InnerText;
Also, if you want to click and do something, using HybridWebView might be a good option, any click events generated from the SVG will be Javascript events and would need to be handled in Javascript code on the web page side. Maybe invoking C# from JavaScript will be used, this requires you know about Javascript .
For more informaton , you can refer:
https://stackoverflow.com/questions/44332451/how-can-i-parse-xml-file-type-of-svg
https://stackoverflow.com/questions/35844589/how-to-change-svgs-path-color/35846034
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/hybridwebview
Best Regards,
Wenyan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
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.
thanks for ur answer @Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) , i have loaded the svg using FFImageLoading, but the problem if can i iterate through this svg file in c# code , or if can i send datafrom xaml.cs to .xaml (i have a method that return a list of locals of building , i was looking here (https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/hybridwebview) and the problem how to fetch the list of locals code into the svg file)
Do you mean that there is a "locals of building" that needs to be drawn on the svg file through c#? Is "locals of building" a list of coordinate points or something else? Maybe SkiaSharp can help you, but I am not sure what you mean.