I\'m trying to do an \"empty list to visibility converter\" for WPF. This is an IValueConverter that takes an object ( that should be a list ) and if the list is empty (or i
You can't cast your list to IList
public class EmptyListVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return Visibility.Collapsed;
else
{
ICollection list = value as ICollection;
if (list != null)
{
if (list.Count == 0)
return Visibility.Collapsed;
else
return Visibility.Visible;
}
else
return Visibility.Visible;
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}