Files
ShrlAlgoToolkit/ShrlAlgoToolkit.Mvvm/Converters/SearchValueConverter.cs
2025-04-24 20:56:44 +08:00

23 lines
748 B
C#

using System.Windows.Data;
namespace ShrlAlgoToolkit.Mvvm.Converters;
public class SearchValueConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var cellText = values[0] == null ? string.Empty : values[0].ToString();
var searchText = values[1] as string;
if (!string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(cellText))
{
return cellText.ToLower().Contains(searchText.ToLower());
}
return false;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
}