private void App_Exit(object sender, ExitEventArgs e) { try { AppVM.Close(); MessageHandlers.UnregisterMessageHandlers(this); } catch (Exception ex) { ExceptionUtils.HandleException(ex); } }
public App(string userConfigPath = null) { MessageHandlers.RegisterMessageHandlers(this); UserConfigPath = GetUserConfigPath(userConfigPath, true); AppViewModel.Init(Assembly.GetEntryAssembly(), this, UserConfigPath); AppVM.LoadAppConfig(); if (!File.Exists(UserConfigPath)) { // Makes sure that LoadUserConfig will be successful AppVM.SaveUserConfig(); } AppVM.LoadUserConfig(HandleUserConfigLoadException); // Makes sure textboxes accept localized inputs FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); Exit += App_Exit; }