using System; using System.Globalization; using System.Windows.Data; namespace TeamAAS_VP.ValueConverter { public class CountToColumnsConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) return 1; if (!int.TryParse(value.ToString(), out int count)) return 1; if (count <= 1) return 1; if (count == 2) return 2; return 3; // 3 或更多时按 3 列分布(UniformGrid 会自动换行) } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException(); } }