How to restore a minimized Window in code-behind?

H.B. picture H.B. · Apr 3, 2011 · Viewed 30.2k times · Source

This is somewhat of a mundane question but it seems to me there is no in-built method for it in WPF. There only seems to be the WindowState property which being an enum does not help since i cannot tell whether the Window was in the Normal or Maximized state before being minimized.

When clicking the taskbar icon the window is being restored just as expected, assuming its prior state, but i cannot seem to find any defined method which does that.

So i have been wondering if i am just missing something or if i need to use some custom interaction logic.

(I'll post my current solution as answer)

Answer

Eric Liprandi picture Eric Liprandi · Jul 27, 2011

Not sure this will work for everybody, but I ran into this today and someone on the team suggested "have you tried Normal