using System; using System.Globalization; using System.Windows.Data; using System.Windows.Media.Imaging; namespace UtopiaCanteenSystem.Converters { /// /// Converts a string URI (e.g. pack:// or file path) to an ImageSource for Image controls. /// public class StringToImageSourceConverter : IValueConverter { public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) { var path = value?.ToString(); if (string.IsNullOrWhiteSpace(path)) return null; try { var uri = new Uri(path, UriKind.RelativeOrAbsolute); return new BitmapImage(uri); } catch { return null; } } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }