using System; using System.Globalization; using System.Windows.Data; using MahApps.Metro.IconPacks; namespace TeamAAS { /// /// 图标 Kind 名(如 "Camera" / "Cog")→ ,供 PackIconMaterial.Kind 绑定用。 /// 为空或无法识别(含遗留的 SVG 路径串)时回退 CircleOutline,保证不崩、不空白。 /// public sealed class IconKindConverter : IValueConverter { /// 把 Kind 名解析为枚举;为空/无法识别(含遗留 SVG 路径)回退 CircleOutline。供 code-behind 复用。 public static PackIconMaterialKind ToKind(string name) { if (!string.IsNullOrWhiteSpace(name) && Enum.TryParse(name.Trim(), ignoreCase: true, out PackIconMaterialKind kind)) return kind; return PackIconMaterialKind.CircleOutline; } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => ToKind(value as string); public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException(); } }