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

后端 未结 7 2002
太阳男子
太阳男子 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:31

    This above solutions did not entirely work for my window - it was too low and the bottom part of the window was beneath the taskbar and below the desktop workspace. I needed to set the position after the window content had been rendered:

    private void Window_ContentRendered(object sender, EventArgs e)
    {
        var desktopWorkingArea = System.Windows.SystemParameters.WorkArea;
        this.Left = desktopWorkingArea.Right - this.Width - 5;
        this.Top = desktopWorkingArea.Bottom - this.Height - 5;
    }
    

    Also, part of the frame was out of view, so I had to adjust by 5. Not sure why this is needed in my situation.

    0 讨论(0)
提交回复
热议问题