private void BtnClose_Click(object sender, RoutedEventArgs e)
 {
     if (sender != null && Window.GetWindow(sender as WindowControlButton) is Window window)
     {
         window.Close();
     }
 }
 private void BtnMinimize_Click(object sender, RoutedEventArgs e)
 {
     if (sender != null && Window.GetWindow(sender as WindowControlButton) is Window window)
     {
         window.WindowState = WindowState.Minimized;
     }
 }
        private void BtnMaximize_OnClick(object sender, RoutedEventArgs e)
        {
            if (sender == null || !(Window.GetWindow(sender as WindowControlButton) is Window window))
            {
                return;
            }

            switch (window.WindowState)
            {
            case WindowState.Maximized:
                window.WindowState = WindowState.Normal;
                break;

            case WindowState.Normal:
                window.WindowState = WindowState.Maximized;
                break;
            }
        }