| 1 | using System; |
| 2 | using System.Collections; |
| 3 | using System.Collections.Generic; |
| 4 | using System.Globalization; |
| 5 | using System.Linq; |
| 6 | using System.Text; |
| 7 | using System.Threading.Tasks; |
| 8 | using System.Windows.Data; |
| 9 | using System.Windows.Media; |
| 10 | |
| 11 | namespace UI.Controls.Converters |
| 12 | { |
| 13 | [ValueConversion(typeof(object), typeof(string))] |
| 14 | public class GetCountConverter : IValueConverter |
| 15 | { |
| 16 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
| 17 | { |
| 18 | if (value == null) return "0"; |
| 19 | var list = value as IEnumerable<object>; |
| 20 | return list == null ? "0" : list.Count().ToString(); |
| 21 | } |
| 22 | |
| 23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
| 24 | { |
| 25 | throw new NotImplementedException(); |
| 26 | } |
| 27 | } |
| 28 | } |