Back to Class Reference home page
System.ComponentModel.INotifyPropertyChanged
MVVMbasics.Models.BaseModel
public abstract class BaseModel : INotifyPropertyChanged
Basic data model, not to be implemented directly, but to be inherited by the actual data models. Contains convenience functions that allow the implementation of INotifyPropertyChanged and some command's CanExecuteChanged
events in code snippets as short as possible.
Constructor Summary | |
---|---|
public |
BaseModel()
Empty constructor. |
Event Summary | |
---|---|
public event PropertyChangedEventHandler |
PropertyChanged
|
Method Summary | |
---|---|
protected void |
Set<T>(ref T field, T value, [CallerMemberName] string propertyName = "")
Setter method that sets the private member field and fires the PropertyChanged event.
|
protected void |
Set<T>(Func<bool>> before, ref T field, T value, [CallerMemberName] string propertyName = "")
Setter method that sets the private member field, fires the PropertyChanged event and calls a specified method to decide whether to continue updating the member field.
|
protected void |
Set<T>(ref T field, T value, Action after, [CallerMemberName] string propertyName = "")
Setter method that sets the private member field, fires the PropertyChanged event and calls a specified method after updating the member field.
|
protected void |
Set<T>(Func<bool>> before, ref T field, T value, Action after, [CallerMemberName] string propertyName = "")
Setter method that sets the private member field, fires the PropertyChanged event and calls two specified methods: One before updating the member field to decide whether to continue, one after updating the member field.
|
protected void |
NotifyPropertyChanged(PropertyChangedEventArgs args)
|
protected void |
NotifyPropertyChanged(string propertyName)
|
protected void |
NotifyPropertyChanged(Expression<Func<T>> property)
|
protected BaseCommand |
CreateCommand(Action execute)
Creates a Command and registers a parameterless method to it. |
protected BaseCommand |
CreateCommand(Action<object> execute)
Creates a Command and registers a method with one parameter of type object to it.
|
protected BaseCommand |
CreateCommand(Action execute, Expression<Func<bool>> canExecute, params Expression<Func<object>>[] dependsOnProperties)
Creates a Command with a CanExecute condition and registers a parameterless method to it.
|
protected BaseCommand |
CreateCommand(Action<object> execute, Expression<Func<object, bool>> canExecute, params Expression<Func<object>>[] dependsOnProperties)
Creates a Command with a CanExecute condition and registers a method with one parameter of type object to it.
|
protected BaseCommand |
CreateAsyncCommand(Func<Task> execute)
Creates an asyncronous Command and registers a parameterless method to it. |
protected BaseCommand |
CreateAsyncCommand(Func<object, Task> execute)
Creates an asyncronous Command and registers a method with one parameter of type object to it.
|
protected BaseCommand |
CreateAsyncCommand(Func<Task> execute, Expression<Func<bool>> canExecute, params Expression<Func<object>>[] dependsOnProperties)
Creates an asyncronous Command with a CanExecute condition and registers a parameterless method to it.
|
protected BaseCommand |
CreateAsyncCommand(Func<object, Task> execute, Expression<Func<object, bool>> canExecute, params Expression<Func<object>>[] dependsOnProperties)
Creates an asyncronous Command with a CanExecute condition and registers a method with one parameter of type object to it.
|
protected void |
Setter method that sets the private member field, fires the PropertyChanged event and optionally fires one or multiple commands' CanExecuteChanged events.
Deprecated. Use method Set instead.
|
protected void |
Setter method that sets the private member field, fires the PropertyChanged event, calls a specified method after updating the member field, and optionally fires one or multiple commands' CanExecuteChanged events.
Deprecated. Use method Set instead.
|