0

I am trying to set my window to the bottom left. The window has no title bar and the height is set to auto and SizeToContent is Height and WindowStartupLocation is Manual

After setting the content I am executing these two lines of code:

Left = SystemParameters.WorkArea.Width - Width - 2; 
Top = SystemParameters.WorkArea.Height - Height - 2;

These two lines are in the SetupWindow() function

InitializeComponent();            

            foreach (Caller c in callers)
            {
                CallerLine callerline = new CallerLine();
                Hyperlink link = (Hyperlink)callerline.FindName("link");
                ContentControl ccname = (ContentControl)callerline.FindName("ccname");
                ContentControl ccnumber = (ContentControl)callerline.FindName("ccnumber");                

                link.RequestNavigate += hyperlink_RequestNavigate;
                ccname.Content = c.Name;
                ccnumber.Content = " " + c.PhoneNumber;

                spCallers.Children.Add(callerline);
            }

            SetupWindow();

I am doing all my setup stuff before I am setting the window to its new position!

Now the window is set somewhere on the Right site of the screen but not on the bottom. How can I set it to the bottom Right?

MP13
  • 390
  • 3
  • 11

1 Answers1

0

The solution was to set the position when the ContentRendered is triggered. here the code:

private void Window_ContentRendered(object sender, EventArgs e)
{
    Left = SystemParameters.WorkArea.Width - Width - 2;
    Top = SystemParameters.WorkArea.Height - Height - 2;
}

MP13
  • 390
  • 3
  • 11