Search code examples
c#wpfwindow-position

Position of notification window at the bottom right corner


I've got a problem with positioning a window. The window is not my main window. I want to position the window to the bottom right corner of my working area above a taskbar.

I have following code:

public partial class NotificationWindow : Window
{
    public NotificationWindow()
    {
        InitializeComponent();
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        Rect desktopWorkingArea = SystemParameters.WorkArea;
        Left = desktopWorkingArea.Right - Width;
        Top = desktopWorkingArea.Bottom - Height;
    }
}

And unwanted result of that code:

enter image description here

I want to have the notification window a little higher above the taskbar. I think my code should work but it does not.

Thanks for advice.


Solution

  • I used this with satisfactory result.

    double width = 375;
    double height = 275;
    
    Window w = new Window();
    w.Width = width;
    w.Height = height;
    w.Left = SystemParameters.FullPrimaryScreenWidth - width;
    w.Top = SystemParameters.FullPrimaryScreenHeight - height;
    
    w.ShowDialog();