0

I try to reset the height of my form in its Loaded event but the position of the form is not centered screen anymore.

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    var manualHeight = 0
        + this.MessageRow.ActualHeight
        + this.ButtonsRow.ActualHeight
    ;
    this.Height = manualHeight;

    //What to do to re-center the form?
}

Please help if you know how to. Great thanks!

Nam.

[Edit]

I re-note the answer here thanks to xandy help.

var screenHeight += System.Windows.SystemParameters.PrimaryScreenHeight;
window.Top = (screenHeight - manualHeight) / 2;
Nam G VU
  • 33,193
  • 69
  • 233
  • 372

1 Answers1

0

manually set the window y position to:

window.Top = (screenHeight - manualHeight) / 2;

where you can have the screenHeight here.

Community
  • 1
  • 1
xandy
  • 27,357
  • 8
  • 59
  • 64