public static ImageSource CreateSvgImage(string relativePath) { var uri = new Uri($"pack://application:,,,/{relativePath}", UriKind.Absolute); var svgHelper = SvgImageHelper.CreateImage(uri); return(WpfSvgRenderer.CreateImageSource(svgHelper, 1d, null, null, true)); }
/// <summary> /// Converts Svg bytes to ImageSource /// </summary> /// <param name="path"></param> /// <returns>a usable <see cref="ImageSource"/></returns> public static ImageSource ToImageSource(Uri path) { using var stream = SvgImageHelper.CreateStream(path); object unused = null; var image = SvgImageHelper.GetOrCreateSvgImage(stream, ref unused); return(WpfSvgRenderer.CreateImageSource(image, 1d, null, null, true)); }