I am currently creating a sidebar-like WPF application in C#. When a user starts the application, I would like the window to automatically position it\'s self to the side of the
You can use Screen
from System.Windows.Forms
.
So add reference to the System.Windows.Forms.dll
and System.Drawing.dll
. Then change the Left
and Height
property in the MainWindow_Loaded
method.
public MainWindow()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
}
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
this.Left = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Right - this.Width;
this.Top = 0;
this.Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
}