private void OnWindowStateChanged(object sender, WindowStateChangedEventArgs e)
 {
     if (e.NewValue == WindowState.Minimized)
     {
         MinimizedWindowsCount++;
     }
     else if (e.OldValue == WindowState.Minimized)
     {
         MinimizedWindowsCount--;
     }
 }
        private static void OnWindowStateChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            var window = obj as MdiWindow;
            if (window != null)
            {
                window.PreviousWindowState = (WindowState)e.OldValue;

                var args = new WindowStateChangedEventArgs(WindowStateChangedEvent, (WindowState)e.OldValue, (WindowState)e.NewValue);
                window.RaiseEvent(args);
            }
        }