StringToImageSourceConverter.cs 684 B

123456789101112131415161718192021222324
  1. using System;
  2. using System.Globalization;
  3. using System.Windows.Data;
  4. using System.Windows.Media.Imaging;
  5. namespace SWRIS.Converters
  6. {
  7. public class StringToImageSourceConverter : IValueConverter
  8. {
  9. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  10. {
  11. if (value is string path)
  12. {
  13. return new BitmapImage(new Uri($"pack://application:,,,/{path}"));
  14. }
  15. return null;
  16. }
  17. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  18. {
  19. throw new NotImplementedException();
  20. }
  21. }
  22. }