Minimize a window in WPF?

后端 未结 7 1307
借酒劲吻你
借酒劲吻你 2020-12-08 12:53

How do you minimize a window programmatically when using windows WPF? I can seem to find a .Resize attribute?

相关标签:
7条回答
  • 2020-12-08 13:27
    this.WindowState = WindowState.Minimized;
    
    0 讨论(0)
  • 2020-12-08 13:29
    YourWindowName.WindowState = WindowState.Minimized;
    
    0 讨论(0)
  • 2020-12-08 13:32

    You are looking for the Window.WindowState property. It is a dependancy property and when changed will set the Window.RestoreBounds property , so you can always restore to the size before the change.

    See the enumeration here.

    myWindow.WindowState = WindowState.Minimized;
    
    0 讨论(0)
  • 2020-12-08 13:33

    set WindowState = WindowState.Minimized;

    0 讨论(0)
  • 2020-12-08 13:42

    Use the window's object WindowState property to programmaticly minimise a window.

    window.WindowState = WindowState.Minimized;
    

    Setting window state to WindowState.Normal will restore the window to it's previous WindowsState, size and location.

    window.WindowState = WindowState.Normal;
    

    Window.Normal is a bit of a misnomer. The remarks in the WindowState property and the WindowState Enumeration MSDN articles hint at WindowState.Normal actual functionality and testing confirms it.

    0 讨论(0)
  • 2020-12-08 13:44

    As many said,

    window.WindowState = WindowState.Minimized

    will minimize the window for you. But be careful about timing - I accidentally set this in a MouseLeftButtonDown handler (vs MouseLeftButtonUp), and the window would not restore.

    0 讨论(0)
提交回复
热议问题