Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the location of WPF window to the bottom right corner of desktop?

I want to show my window on top of the TaskBar's clock when the windows starts.

How can I find the bottom right corner location of my desktop?

I use this code that works well in windows forms app but does not work correctly in WPF:

var desktopWorkingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea; this.Left = desktopWorkingArea.Right - this.Width; this.Top = desktopWorkingArea.Bottom - this.Height; 
like image 867
VirtualWorld Avatar asked Oct 01 '11 13:10

VirtualWorld


1 Answers

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

like image 168
Klaus78 Avatar answered Oct 05 '22 11:10

Klaus78