using System; using System.Windows.Controls; using System.Windows.Data; namespace Szmedi.RvKits.Converters { public class SearchTypeValueConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string cellText = values[0] == null ? string.Empty : values[0].ToString(); string searchText = values[1] as string; DataGridCell cell = values[2] as DataGridCell; var head = cell?.Column?.Header?.ToString(); return head is "族类型" && !string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(cellText) ? cellText.Contains(searchText) : (object)false; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { return null; } } public class SearchFamilyValueConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string cellText = values[0] == null ? string.Empty : values[0].ToString(); string searchText = values[1] as string; DataGridCell cell = values[2] as DataGridCell; var head = cell?.Column?.Header?.ToString(); return head is "族名称" && !string.IsNullOrEmpty(searchText) && !string.IsNullOrEmpty(cellText) ? cellText.Contains(searchText) : (object)false; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { return null; } } }