IsMaximizedConverter.cs 894 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Globalization;
  3. using Avalonia.Controls;
  4. using Avalonia.Data.Converters;
  5. namespace Dock.Avalonia.Converters;
  6. /// <summary>
  7. /// Converts WindowState to bool indicating if the window is maximized.
  8. /// </summary>
  9. public class IsMaximizedConverter : IValueConverter
  10. {
  11. /// <summary>
  12. /// Gets <see cref="IsMaximizedConverter"/> instance.
  13. /// </summary>
  14. public static IsMaximizedConverter Instance { get; } = new();
  15. /// <inheritdoc/>
  16. public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
  17. {
  18. if (value is WindowState windowState)
  19. {
  20. return windowState == WindowState.Maximized;
  21. }
  22. return false;
  23. }
  24. /// <inheritdoc/>
  25. public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
  26. {
  27. return null;
  28. }
  29. }