WindowStateToThicknessConverter.cs 864 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.Globalization;
  3. using System.Windows.Data;
  4. using System.Windows;
  5. namespace Compdfkit_Tools.Common
  6. {
  7. [ValueConversion(typeof(WindowState), typeof(Thickness))]
  8. public class WindowStateToThicknessConverter : IValueConverter
  9. {
  10. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  11. {
  12. var ws = (WindowState)value;
  13. if (ws == WindowState.Maximized)
  14. {
  15. return new Thickness(6);
  16. }
  17. else
  18. {
  19. // left, right and bottom borders are still drawn by the system
  20. return new Thickness(2);
  21. }
  22. }
  23. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  24. {
  25. return null;
  26. }
  27. }
  28. }