How do I know whether the System.Windows.Window was in WindowState.Normal or WindowState.Maximized before it was minimized?
You don't unless you keep track of the previous state yourself:
private WindowState _previousState = WindowState.Normal;
private void MainWindow_StateChanged(object sender, EventArgs e)
{
if (WindowState == WindowState.Minimized)
{
if (_previousState == WindowState.Maximized)
{
MessageBox.Show("Window was in maximized state before being minimized");
}
else
{
MessageBox.Show("Window was in normal state before being minimized");
}
}
_previousState = WindowState;
}
I am afraid there is no "PreviousWindowState" property available.