25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.4 KiB

  1. using BPA.UIControl.Commons;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Globalization;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows.Controls;
  9. using System.Windows.Controls.Primitives;
  10. using System.Windows.Data;
  11. namespace BPA.UIControl.Converters
  12. {
  13. /// <summary>
  14. /// 获取 DataGridColumn 的 CheckedContent 属性
  15. /// </summary>
  16. public class GetDataGridColumnCheckedContentConverter : IMultiValueConverter
  17. {
  18. /// <inheritdoc/>
  19. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  20. {
  21. if (values.Length < 2)
  22. {
  23. throw new ArgumentException("the values length can't be less the 2.");
  24. }
  25. var dataGrid = ValidateArgument.NotNullOrEmptyCast<DataGrid>(values[0], "values[0]");
  26. var columnHeader = ValidateArgument.NotNullOrEmptyCast<DataGridColumnHeader>(values[1], "values[1]");
  27. foreach (var column in dataGrid.Columns)
  28. {
  29. if (columnHeader.Column == column)
  30. {
  31. return ToggleButtonHelper.GetCheckedContent(column) ?? column.Header;
  32. }
  33. }
  34. return null;
  35. }
  36. /// <inheritdoc/>
  37. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  38. {
  39. return null;
  40. }
  41. }
  42. }