When using some svg files as input, the xaml is invalid.
Example: https://upload.wikimedia.org/wikipedia/commons/4/48/Complex_Color_map.svg
svgFilePath = @"Complex_Color_map.svg";
var settings = new WpfDrawingSettings
{
IncludeRuntime = false,
TextAsGeometry = true
};
using (var reader = new FileSvgReader(settings))
{
DrawingGroup drawingGroup = reader.Read(svgFilePath);
string xaml;
using (var stringWriter = new StringWriter())
using (var xmlWriter = new XmlTextWriter(stringWriter) { Formatting = Formatting.Indented })
{
XamlWriter.Save(drawingGroup, xmlWriter);
xaml = stringWriter.ToString();
}
string path = Path.Combine(@"D:\_Cases\SVG\", Path.GetFileNameWithoutExtension(svgFilePath) + ".xaml");
File.WriteAllText(path, xaml);
}
Complex_Color_map.xaml contains:
<BitmapImage BaseUri="{x:Null}" CreateOptions="PreservePixelFormat" />
This is invalid and later cause exceptions when the xaml is used (for example in XamlReader.Load())

When using some svg files as input, the xaml is invalid.
Example: https://upload.wikimedia.org/wikipedia/commons/4/48/Complex_Color_map.svg
Complex_Color_map.xaml contains:
<BitmapImage BaseUri="{x:Null}" CreateOptions="PreservePixelFormat" />This is invalid and later cause exceptions when the xaml is used (for example in XamlReader.Load())