For centering, use Window.WindowStartupLocation
and Window.Owner
:
//"dialog" being your child window
//"this" being your calling window
dialog.Owner = this;
dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
Alternatively, you could set WindowStartupLocation="CenterOwner"
in the XAML of your child window instead of in code.
For resizing, you can set your child window to be some percentage of your main window's size, or of the user's screen:
//Child window would 25% the size of the caller.
double scale = 0.25;
dialog.Width = this.Width * scale;
dialog.Height = this.Height * scale;
//Or 25% the size of the screen
dialog.Width = System.Windows.SystemParameters.WorkArea.Width * scale;
dialog.Height = System.Windows.SystemParameters.WorkArea.Height * scale;
Note that SystemParameters.WorkArea
gives you the dimentions of the "primary screen", so this might not work right in a multi-monitor setup. If that's a problem you can look at this question.