Esempio n. 1
0
        /// <summary>
        /// Called when a loaded data model is closing.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="eventArgs">The <see cref="ClosingEventArgs"/> instance containing the event data.</param>
        protected virtual void OnClosing(object sender, ClosingEventArgs eventArgs)
        {
            //this.FlushBindings (); ** Uncomment when we have C# 3.0 support **
            Extensions.FlushBindings(this);

            if (!eventArgs.Cancel && this.ViewModel.HasUnsavedChanges)
            {
                MessageBoxResult messageBoxResult = MessageBox.Show(this, Properties.WpfViewResources.QuerySaveMessageString, Properties.WpfViewResources.QuerySaveCaptionString, MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Yes);
                if (messageBoxResult == MessageBoxResult.Cancel)
                {
                    eventArgs.Cancel = true;
                }
                else if (messageBoxResult == MessageBoxResult.Yes)
                {
                    eventArgs.Cancel = !SaveCommand <TController, TModel> .Save(this.ViewModel, this);
                }
            }
        }
Esempio n. 2
0
 internal static bool CanExecute(ViewModel <TController, TModel> viewModel, object parameter)
 {
     return(SaveCommand <TController, TModel> .CanSave(viewModel));
 }
Esempio n. 3
0
 internal static void Execute(ViewModel <TController, TModel> viewModel, Window owner, object parameter)
 {
     SaveCommand <TController, TModel> .Save(viewModel, owner, parameter as string);
 }
Esempio n. 4
0
 /// <summary>
 /// Saves the data model for the specified <see cref="ViewModel&lt;TController, TModel&gt;"/>.
 /// </summary>
 /// <param name="viewModel">The view model.</param>
 /// <param name="owner">The owner window.</param>
 /// <returns>
 ///     <c>true</c> if the data model is saved; otherwise, <c>false</c>.
 /// </returns>
 public static bool Save(ViewModel <TController, TModel> viewModel, Window owner)
 {
     return(SaveCommand <TController, TModel> .Save(viewModel, owner, null));
 }