Hi DevExpress Team,
i have the following problem. I use the svg converter that you show in this support ticket:T602474. It worked well, when I put the images in the same directory as the view. But as u can see in the picture i have the views in another folder than the svg files. When I manipulate the Uri in the converter like this:
C#public class SvgImageSourceConverterExtension : MarkupExtension, IValueConverter {
class UriStreamHelper : SvgImageSourceExtension { public static Stream GetStream(Uri uri) { return CreateRequestAndGetResponseStream(uri); } }
readonly Uri baseUri;
readonly UriTypeConverter uriConverter;
public static Uri Parent(Uri uri)
{
var newUri= new Uri(uri, Path.GetDirectoryName(uri.LocalPath) + "/");
return new Uri(newUri.AbsoluteUri.Remove(newUri.AbsoluteUri.Length - newUri.Segments[newUri.Segments.Length -1].Length - newUri.Query.Length) + "Rescources/");
}
public SvgImageSourceConverterExtension() : this(null) { }
public SvgImageSourceConverterExtension(Uri baseUri)
{
if (baseUri == null)
{
this.baseUri = baseUri;
}
else
{
var uri = new Uri(baseUri, ".");
this.baseUri = Parent(uri);
}
uriConverter = new UriTypeConverter();
}
public override object ProvideValue(IServiceProvider serviceProvider) { return new SvgImageSourceConverterExtension((serviceProvider.GetService(typeof(IUriContext)) as IUriContext)?.BaseUri); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var uri = uriConverter.ConvertFrom(value) as Uri;
if (uri == null)
return null;
var absoluteUri = uri.IsAbsoluteUri ? uri : new Uri(baseUri, uri);
using (var stream = UriStreamHelper.GetStream(absoluteUri))
{
object unused = null;
var image = SvgImageHelper.GetOrCreateSvgImage(stream, ref unused);
return WpfSvgRenderer.CreateImageSource(image, 1d, null, null, true);
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); }
}
It wanna find the file in the debug bin. The xaml, which use the converter is in the view folder. I use the converter to change the svg image if a property in my TableView change to false.I hope you can help me to fix this behaviour.