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

后端 未结 7 2026
太阳男子
太阳男子 2020-12-07 20:39

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?

7条回答
  •  渐次进展
    2020-12-07 21:08

    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

提交回复
热议问题