WindowMinimizeCommand.cs 724 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Input;
  8. namespace WpfStyleableWindow.StyleableWindow
  9. {
  10. public class WindowMinimizeCommand :ICommand
  11. {
  12. public bool CanExecute(object parameter)
  13. {
  14. return true;
  15. }
  16. #pragma warning disable 0067
  17. public event EventHandler CanExecuteChanged;
  18. #pragma warning restore 0067
  19. public void Execute(object parameter)
  20. {
  21. var window = parameter as Window;
  22. if (window != null)
  23. {
  24. window.WindowState = WindowState.Minimized;
  25. }
  26. }
  27. }
  28. }