public static void CenterWindowToSize(this Window window, Rect parentRect) { Argument.IsNotNull(() => window); var windowWidth = window.Width; var windowHeight = window.Height; window.SetCurrentValue(Window.LeftProperty, parentRect.Left + (parentRect.Width / 2) - (windowWidth / 2)); window.SetCurrentValue(Window.TopProperty, parentRect.Top + (parentRect.Height / 2) - (windowHeight / 2)); }
public static void SetMaximumWidth(this Window window) { Argument.IsNotNull(() => window); window.SetCurrentValue(FrameworkElement.MaxWidthProperty, SystemParameters.WorkArea.Width - 40); }