How to set the location of WPF window to the bottom right corner of desktop?
To access the desktop rectangle, you could use the Screen class - Screen.PrimaryScreen.WorkingArea
property is the rectangle of your desktop.
Your WPF window has Top
and Left
properties as well as Width
and Height
, so you could set those properties relative to the desktop location.
This code works for me in WPF both with Display 100% and 125%
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var desktopWorkingArea = System.Windows.SystemParameters.WorkArea;
this.Left = desktopWorkingArea.Right - this.Width;
this.Top = desktopWorkingArea.Bottom - this.Height;
}
In brief I use
System.Windows.SystemParameters.WorkArea
instead of
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea