using System; using System.Collections.Generic; using System.Globalization; using Avalonia; using Avalonia.Data.Converters; using Avalonia.Metadata; namespace Semi.Avalonia.Demo.Converters; public class FileIconConverter : IMultiValueConverter { [Content] public IDictionary Items { get; } = new Dictionary(); public object? Convert(IList values, Type targetType, object? parameter, CultureInfo culture) { if (values[0] is bool isDirectory && values[1] is bool isOpen) { if (!isDirectory) { return Items["file"]; } return isOpen ? Items["folderOpen"] : Items["folderClosed"]; } return AvaloniaProperty.UnsetValue; } }