public void CustomMessageWindow_Loaded(object sender, RoutedEventArgs e) { if (this.Owner == null || InteropWindow.FindMainWindowState((Window)this) == WindowState.Minimized) { this.WindowStartupLocation = WindowStartupLocation.CenterScreen; } if (this.mButton2 == null) { return; } this.UpdateLayout(); }
public static WindowState FindMainWindowState(Window window) { return(window?.Owner == null ? window.WindowState : InteropWindow.FindMainWindowState(window.Owner)); }