CenterToolTipConverter .cs 948 B

123456789101112131415161718192021222324252627282930
  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;
  8. using System.Windows.Data;
  9. namespace PDF_Master.DataConvert
  10. {
  11. public class CenterToolTipConverter : IMultiValueConverter
  12. {
  13. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  14. {
  15. if (values.FirstOrDefault(v => v == DependencyProperty.UnsetValue) != null)
  16. {
  17. return double.NaN;
  18. }
  19. double placementTargetWidth = (double)values[0];
  20. double toolTipWidth = (double)values[1];
  21. return (placementTargetWidth / 4.0*3) - (toolTipWidth / 2.0);
  22. }
  23. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  24. {
  25. throw new NotSupportedException();
  26. }
  27. }
  28. }