private async void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { // Disable managed controls WindowUtils.SetForceSoftwareRendering(this); IsEnabled = false; // Get IntPtr handle for this Window var handle = new WindowInteropHelper(this).Handle; // Set native disabled state to disallow moving window WindowUtils.TrySetNativeEnabled(false, handle); var startup = new StartupLoadingWindow { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner, CanClose = false }; try { startup.Show(); await _vm.InitializeNhm(startup.StartupLoader); } finally { // Remove disabled native bit // NOTE must happen before startup.Close() or else minimizing thing happens WindowUtils.TrySetNativeEnabled(true, handle); startup.CanClose = true; // If owner is still set to `this` when close is called, // it will minimize the main window for some reason startup.Owner = null; startup.Close(); // Re-enable managed controls IsEnabled = true; } }
private async void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { IsEnabled = false; var startup = new StartupLoadingWindow { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner, CanClose = false }; startup.Show(); await _vm.InitializeNhm(startup.StartupLoader); startup.CanClose = true; // If owner is still set to this when close is called, // it will minimize the main window for some reason startup.Owner = null; startup.Close(); IsEnabled = true; }