i have WPF application and i want to maximize main window. i tried the below code but the issue is that the window is maximized but not centered. i want the window to be maximized as i maximize window with mouse click. my code is:
mainWindow.Height = SystemParameters.MaximizedPrimaryScreenHeight;
mainWindow.Width = SystemParameters.MaximizedPrimaryScreenWidth;
Set the
WindowState
property instead ofWidth
andHeight
: