Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 891305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:52:07+00:00 2026-05-15T13:52:07+00:00

According to the MSDN documentation for the WindowStartupLocation Property : Setting CenterScreen causes a

  • 0

According to the MSDN documentation for the WindowStartupLocation Property:

Setting CenterScreen causes a window to be positioned in the center of the screen that contains the mouse cursor.

Although the MSDN doc for the CenterScreen Field itself defines it somewhat less clearly as:

The startup location of a window is the center of the screen on which it is opened.

A simple test shows this working as it should:

MainWindow.xaml

<Window x:Class="CenterScreenTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Button Click="button_Click">Open Window</Button>
</Window>

MainWindow.xaml.cs

using System.Windows;

namespace CenterScreenTest
{
    public partial class MainWindow
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        void button_Click(object sender, RoutedEventArgs e)
        {
            Window window = new Window();
            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.Show();
        }
    }
}

If you test this out on a dual monitor system, you can see that the new window will be centered on the screen where the mouse cursor is when you click the button. That’s exactly how it should work.

However, if you try to set the window to maximize before you show it, the new window will only maximize on the display from which you launched the application. Change the button_Click event handler to the following to see what I mean:

void button_Click(object sender, RoutedEventArgs e)
{
    Window window = new Window();
    window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
    window.WindowState = WindowState.Maximized;
    window.Show();
}

Now the window will only maximize on the screen from which the application is launched, no matter where the mouse cursor is when you click the button. If you set the window state to maximized after you show it, CenterScreen works properly. This is equivalent to the user maximizing the window. For instance:

void button_Click(object sender, RoutedEventArgs e)
{
    Window window = new Window();
    window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
    window.Show();
    window.WindowState = WindowState.Maximized;
}

The problem here, of course, is that maximizing the window after showing it takes much longer and in an app such as mine, the window needs to pop into place immediately.

Anyone know of a solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:52:08+00:00Added an answer on May 15, 2026 at 1:52 pm

    I asked the same question on the MSDN WPF Forum and got an answer with this awesome workaround:

    void button_Click(object sender, RoutedEventArgs e)
    {
        Window window = new Window();
        window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
        window.SourceInitialized += (s, a) => window.WindowState = WindowState.Maximized;
        window.Show();
    }
    

    I’ve also submitted a bug report about this issue to Microsoft that they are currently reviewing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 533k
  • Answers 533k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer what country? Maybe you want to checkout Geonames: http://www.geonames.org/ Especially:… May 17, 2026 at 12:38 am
  • Editorial Team
    Editorial Team added an answer The important part of the close is what's happening on… May 17, 2026 at 12:38 am
  • Editorial Team
    Editorial Team added an answer A few things to keep in mind: It was designed… May 17, 2026 at 12:38 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

According to MSDN documentation, SetupDiGetClassDevs can be passed a device instance ID to obtain
According to MSDN Documentation for partial classes : Partial methods are implicitly private So
I have set the ActiveDirectoryMembershipProvider connectionProtection attribute to secure, according to MSDN documentation states
According to the MSDN Documentation for ThreadState , the Stopped state can be entered
According to MSDN documentation this proc is supposed to grant login to a windows
According to the MSDN documentation , transactional NTFS doesn't seem to allow one to
According to MSDN, System.Int32 is immutable, and its members always return new instances. Some
I have a small WinForms app that utilizes a BackgroundWorker object to perform a
I am working on a class that maintains a dictionary of images. This dictionary
From Don Syme blog ( http://blogs.msdn.com/b/dsyme/archive/2010/01/10/async-and-parallel-design-patterns-in-f-reporting-progress-with-events-plus-twitter-sample.aspx ) I tried to implement a twitter stream

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.