ListViewWidthConverter.cs 1.0 KB

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