19 lines
561 B
C#
19 lines
561 B
C#
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();
|
|
}
|
|
} |