How to trigger an event related to maximization in C #

Consider the following code:

Window myWindow = new MyWindowSubclass();
myWindow.BringIntoView();
myWindow.Show();

// Code which is effective as pressing the maximize button

Also, how to determine if a window is really in a maximized state.

+3
source share
3 answers

In WPF, you can use the WindowState property :

myWindow.WindowState = WindowState.Maximized;

Of course, you can request this property to get the current state of the window:

if (myWindow.WindowState == WindowState.Maximized) {
    // Window is currently maximized.
}
+3
source

For WinForms you can use

bool maximized = this.WindowState == System.Windows.Forms.FormWindowState.Maximized;

to check if the window is maximized.

Events SizeChangedand Resizeshould record all window state changes.

+1
source

WinForms

// Code which is effective as pressing the maximize button
myWindow.WindowState = FormWindowState.Maximized;

, :

if (myWindow.WindowState == FormWindowState.Maximized) { ... }
+1

All Articles