Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the start up location of a WPF window

I'd like to have a WPF window open in the top right part of the screen.

Right now I can achieve that by opening the window and then moving it (via movewindow in user32.dll). However, this approach means the window opens in it's default location, fully loads, and then moves to the top right.

How could I do I change it so that I could specify the window's initial position and size?

like image 817
Evan Avatar asked Oct 09 '09 18:10

Evan


People also ask

How do I change the startup window in WPF?

If you look at App. xaml class of your WPF application, you will see the following XAML code. Here the StartupUri sets the startup Window of an application. If you want to change the Startup window to some other window, just change this value.

Where does a WPF application start?

For a WPF standalone application that is generated in Visual Studio using the New Project wizard, the entry point for the application is the Main function, defined in App. g. cs (generated code). In the default project, this is the public static void App.


1 Answers

Just set WindowStartupLocation, Height, Width, Left, and Top in xaml:

<Window x:Class="WpfApplication1.Window1"      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"      Title="Window1"      Height="500" Width="500"     WindowStartupLocation="Manual"      Left="0" Top="0"> </Window> 
like image 180
Reed Copsey Avatar answered Sep 22 '22 01:09

Reed Copsey