diff --git a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs index e259efcf52e..c8119d62998 100644 --- a/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs @@ -38,10 +38,7 @@ public PreferencesView(DynamoViewModel dynamoViewModel) Actions.Open, Categories.Preferences); - //If we want the PreferencesView window to be modal, we need to assign the owner (since we created a new Style and not following the common Style) - this.Owner = Application.Current.MainWindow; - var viewModelTemp = DataContext as PreferencesViewModel; - if (viewModelTemp != null) + if (DataContext is PreferencesViewModel viewModelTemp) { viewModel = viewModelTemp; } diff --git a/src/DynamoCoreWpf/Views/PackageManager/PackagePathView.xaml.cs b/src/DynamoCoreWpf/Views/PackageManager/PackagePathView.xaml.cs index a55b8596258..c87c1c00d70 100644 --- a/src/DynamoCoreWpf/Views/PackageManager/PackagePathView.xaml.cs +++ b/src/DynamoCoreWpf/Views/PackageManager/PackagePathView.xaml.cs @@ -1,14 +1,9 @@ using System; -using System.ComponentModel; -using System.Linq; using System.Windows; -using System.Windows.Controls; using System.Windows.Forms; -using System.Windows.Input; using Dynamo.UI; using Dynamo.ViewModels; using DynamoUtilities; -using KeyEventArgs = System.Windows.Input.KeyEventArgs; namespace Dynamo.Wpf.Views.PackageManager { @@ -69,8 +64,8 @@ private void OnRequestShowFileDialog(object sender, EventArgs e) { // Navigate to initial folder. SelectedPath = args.Path, - Owner = System.Windows.Application.Current.Windows.OfType().SingleOrDefault(x => x.IsActive) - }; + Owner = Window.GetWindow(this) + }; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {