I have a windowless wpf application, whenever I set the window state as maximized it maximizes it on the primary display.
What I would like to do is have it maximize on
We cannot maximize the window until it's loaded. So by hooking the Loaded event of fullScreenWindow and handling the event along the lines of:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Maximized;
}
I just ran into the same problem. In my case it turned out to be the fact that I was Hiding my pop up window when I was done with it. So if I called it next time and asked it to Maximize, it would do it on the original screen. Once I started Closing it instead, it started to maximize on the proper screen.
I've included this line on my MainWindow (first control) constructor:
Application.Current.MainWindow.WindowState = WindowState.Maximized;
c# application first starts on the primary display, unless it is moved your code will work. However, if your wpf app will be moved to another display new location can be recorded and stored in a local config file. But, your app will have no borders or any other native controls so you will also have to implement the moving bit. and when your window is moved you will be able to capture the display index using SystemParameters.
Good Luck
Because of the taskbar you should use user working area's size:
this.Width=SystemParameters.WorkArea.Width;
this.Height=SystemParameters.WorkArea.Height;
You can use this in view's constructor
I asked a similar question that you might find helpful. How Can I Make a WPF Window Maximized on the Screen with the Mouse Cursor?