重构中day1,写了很多,不知道怎么说清楚

This commit is contained in:
fengjiayi
2025-03-18 21:01:15 +08:00
parent 87402ec7ea
commit 2168c5ec66
39 changed files with 2809 additions and 10 deletions

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows;
namespace Serein.Workbench.Converters
{
public class CountToVisibilityConverter : IValueConverter
{
public bool Inverse { get; set; } = false; // 可选:反转逻辑
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is IEnumerable collection)
{
int count = 0;
foreach (var item in collection) count++;
bool visible = count > 0;
if (Inverse) visible = !visible;
return visible ? Visibility.Visible : Visibility.Collapsed;
}
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
}
}