WIn_RustTools/RustTools/Helpers/UriToImageSourceConverter.cs

19 lines
561 B
C#
Raw Normal View History

2024-07-19 14:29:49 +00:00
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Media.Imaging;
public class UriToImageSourceConverter : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, string language)
{
if (value is string imageUrl && !string.IsNullOrEmpty(imageUrl))
{
return new BitmapImage(new Uri(imageUrl));
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}