private Window CreateSettingsExperience() { var defaultCategory = new SettingsCategoryViewModel( EarTrumpet.Properties.Resources.SettingsCategoryTitle, "\xE71D", EarTrumpet.Properties.Resources.SettingsDescriptionText, null, new SettingsPageViewModel[] { new EarTrumpetShortcutsPageViewModel(_settings), new EarTrumpetLegacySettingsPageViewModel(_settings), new EarTrumpetAboutPageViewModel(() => _errorReporter.DisplayDiagnosticData(AddonManager.GetDiagnosticInfo())) }.ToList()); var allCategories = new List <SettingsCategoryViewModel>(); allCategories.Add(defaultCategory); if (AddonManager.Host.SettingsItems != null) { allCategories.AddRange(AddonManager.Host.SettingsItems.Select(a => a.Get(AddonManager.FindAddonInfoForObject(a)))); } bool canClose = false; var viewModel = new SettingsViewModel(EarTrumpet.Properties.Resources.SettingsWindowText, allCategories); var window = new SettingsWindow { DataContext = viewModel }; window.CloseClicked += () => viewModel.OnClosing(); viewModel.Close += () => { canClose = true; window.SafeClose(); }; window.Closing += (_, e) => { if (canClose) { _settingsWindow.Destroyed(); } else { e.Cancel = true; viewModel.OnClosing(); } }; return(window); }