I have a window in an application created with WPF and C#. I have set MaxHeight=200, MaxWidth=500 and StartupLocation=CenterScreen.However maximizing this window makes it positioned on the left upper region of the screen i.e: not in the center any more! The maximized window is always on the left upper part even though I set Left=200 and Top=200 in the Window_StateChanged event on the condition of maximizing.
private void Window_StateChanged(object sender, EventArgs e)
{
if (this.WindowState == WindowState.Maximized)
{
// Left = System.Windows.SystemParameters.WorkArea.Width - Width;
Left = 200;
// Top = System.Windows.SystemParameters.WorkArea.Height - Height;
Top = 200;
}
}
What should I do to make sure the maximized windows is positioned in the center? Thanks very much in advance.