using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml;
using System;
using System.Collections;

namespace Harmonia.WinUI.Converters;

public sealed partial class NullVisibilityConverter : IValueConverter
{
    public NullVisibilityConverter()
    {

    }

    public object Convert(object value, Type targetType, object parameter, string language)
    {
        if (value is not IList list)
            return value == null ? Visibility.Collapsed : Visibility.Visible;
        
        return list.Count == 0 ? Visibility.Collapsed : Visibility.Visible;
    }

    public object ConvertBack(object value, Type targetType, object parameter, string language)
    {
        throw new NotImplementedException();
    }
}