ListViewWidthConverter.cs 940 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Globalization;
  3. using System.Windows.Data;
  4. using System.Windows;
  5. namespace Compdfkit_Tools.Common
  6. {
  7. public class ListViewWidthConverter : IValueConverter
  8. {
  9. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  10. {
  11. if (value == null)
  12. {
  13. return 0;
  14. }
  15. else
  16. {
  17. if (value is double)
  18. {
  19. double width = (double)value;
  20. width = width - SystemParameters.VerticalScrollBarWidth - 8;
  21. return Math.Max(0, width);
  22. }
  23. else
  24. {
  25. return 0;
  26. }
  27. }
  28. }
  29. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  30. {
  31. return null;
  32. }
  33. }
  34. }