|Available on||.NET Framework 4.5, .NET Framework 4.6, Portable Class Libraries, Xamarin - Android, Xamarin - iOS|
public abstract class ViewModelBase : IUniqueIdentifyable, IRelationalViewModel, ValidatableModelBase
Base types ValidatableModelBase
View model base for MVVM implementations. This class is based on the ModelBase, and supports all common interfaces used by WPF.
This view model base does not add any services.
Gets a value indicating whether this object contains any field or business errors.
Gets a value indicating whether this instance is closed. If a view model is closed, calling CancelViewModelAsync, SaveViewModelAsync or Boolean}) will have no effect.
Gets the parent view model.
Gets the title of the view model.
Gets the unique identifier of the view model.
Gets the view model construction time, which is used to get unique instances of view models.
Occurrs when the view model is canceled.
Occurs when the view model is about to be canceled.
Occurs when the view model has just been closed.
Occurs when the view model is being closed.
Occurs when a command on the view model has been executed.
Occurs when the view model has been initialized.
Occurs when the navigation is completed.
This should of course be a cleaner solution, but there is no other way to let a view-model know that navigation has completed. Another option is injection, but this would require every view-model for Windows Phone 7 to accept only the navigation context, which has actually nothing to do with the logic. It is also possible to use the OnNavigationCompleted event.
Occurs when the view model is saved successfully.
Occurs when the view model is about to be saved.
Cancels the editing of the data.
true if successful; otherwise
Closes this instance. Always called after the CancelAsync of SaveAsync method.
|result||The result to pass to the view. This will, for example, be used as
Initializes the view model. Normally the initialization is done in the constructor, but sometimes this must be delayed to a state where the associated UI element (user control, window, …) is actually loaded. This method is called as soon as the associated UI element is loaded.
It’s not recommended to implement the initialization of properties in this method. The initialization of properties should be done in the constructor. This method should be used to start the retrieval of data from a web service or something similar. During unit tests, it is recommended to manually call this method because there is no external container calling this method.
Saves the data.
true if successful; otherwise
Converts the object to a string.
Updates the navigation context. The navigation context provided by this class is different from the NavigationContext. Therefore, this method updates the navigation context to match it to the values of the navigationContext.
|navigationContext||The navigation context.|
Validates the current object for field and business rule errors.
|force||If set to
To check whether this object contains any errors, use the ValidationContext property.
Have a question about Catel? Use StackOverflow with the Catel tag!