Class ExtendableViewModelBase
Viewmodel base which enabled adding custom properties to the viewmodel
Implements
Inherited Members
Namespace: Simplic.UI.MVC
Assembly: Simplic.UI.dll
Syntax
public abstract class ExtendableViewModelBase : CustomTypeHelper, ICustomTypeProvider, IExtendableViewModel, IViewModelBase, INotifyPropertyChanged, INotifyDataErrorInfo, IValidateableViewModel, IAsyncViewModel
Constructors
| Improve this Doc View SourceExtendableViewModelBase()
Create new model base
Declaration
public ExtendableViewModelBase()
Properties
| Improve this Doc View SourceForceSave
get or set a state which indicates if something has changed and needs to be saved. Passes the ForceSave value to the Parent Used by DefaultRibbonWindow to call the OnSave method
Declaration
[Browsable(false)]
public bool ForceSave { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
HasErrors
Gets whether validation errors exists or not
Declaration
public bool HasErrors { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsBusy
Gets or sets whether the view model is processing data
Declaration
[Browsable(false)]
public bool IsBusy { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsDirty
Get/Set wether the values has changed in the current ViewModel instance. The default-value is false
Declaration
[Browsable(false)]
public bool IsDirty { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsInValidationMode
Gets or sets whether validation mode is active
Declaration
public bool IsInValidationMode { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Parent
gets or sets the parent ViewModel
Declaration
[Browsable(false)]
public IViewModelBase Parent { get; set; }
Property Value
Type | Description |
---|---|
UI.MVC.IViewModelBase |
Validators
Gets a list of all validators
Declaration
public IList<string> Validators { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<System.String> |
Methods
| Improve this Doc View SourceAddValidator(String, IPropertyValidator)
Add a validator for a property
Declaration
public void AddValidator(string propertyName, IPropertyValidator validator)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | PropertyName |
IPropertyValidator | validator | Validator instance |
AddValidator(String, IPropertyValidator, String)
Add a validator for a property
Declaration
public void AddValidator(string propertyName, IPropertyValidator validator, string customMessage)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | PropertyName |
IPropertyValidator | validator | Validator instance |
System.String | customMessage | Own message if invalid |
AllowTenantChange()
Determines whether a tenant change is allowed.
Declaration
public virtual bool AllowTenantChange()
Returns
Type | Description |
---|---|
System.Boolean |
CollectionNotifyPropertyChanged<Model, ViewModel>(ObservableCollection<ViewModel>, ICollection<Model>, Func<ViewModel, Model>)
Viewmodel collection change notification
Declaration
protected void CollectionNotifyPropertyChanged<Model, ViewModel>(ObservableCollection<ViewModel> observableCollection, ICollection<Model> statefulCollection, Func<ViewModel, Model> getModel)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.ObjectModel.ObservableCollection<ViewModel> | observableCollection | Observable collection instance |
System.Collections.Generic.ICollection<Model> | statefulCollection | Stateful collection instance |
System.Func<ViewModel, Model> | getModel | Delegate/Method to get the Model from the ViewModel |
Type Parameters
Name | Description |
---|---|
Model | Type of model in the stateful collection |
ViewModel | Type of viewmodel in the observable collection |
CustomPropertyChanged(String, Object)
Will be called when a custom property gets changed
Declaration
public virtual void CustomPropertyChanged(string name, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the property that way changed |
System.Object | value |
CustomPropertyGetter(String, Object, PropertyInfo)
Will be called when getting values from the getter
Declaration
public virtual object CustomPropertyGetter(string name, object value, PropertyInfo propertyInfo)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the property |
System.Object | value | Value that is currently stored in the field of the property |
System.Reflection.PropertyInfo | propertyInfo | Property informatiopn |
Returns
Type | Description |
---|---|
System.Object | Value to return from the getter |
CustomPropertySetter(String, Object, out Object, PropertyInfo)
Will be called before the custom property is changed
Declaration
public virtual bool CustomPropertySetter(string name, object inValue, out object outValue, PropertyInfo propertyInfo)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the property to change |
System.Object | inValue | Value that was passed into the setter |
System.Object | outValue | Value that should be set |
System.Reflection.PropertyInfo | propertyInfo | Property information |
Returns
Type | Description |
---|---|
System.Boolean | True if the setter should set the value |
GetErrors(String)
Get all enumeration errors
Declaration
public IEnumerable GetErrors(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | Property to get the errors of |
Returns
Type | Description |
---|---|
System.Collections.IEnumerable | List of errors |
JsonDeserializeValidators(String)
Deserialize validators configuration
Declaration
public void JsonDeserializeValidators(string json)
Parameters
Type | Name | Description |
---|---|---|
System.String | json | Validators as json string |
JsonSerializeValidators()
Serialize validators
Declaration
public string JsonSerializeValidators()
Returns
Type | Description |
---|---|
System.String | Validators as string |
OnClose()
Called when DefaultRibbonWindow closes used to clear locks
Declaration
public virtual void OnClose()
PropertySetter<T>(T, Action<T>, Boolean, Boolean, Boolean, String)
Property setter wrapper to set property values and call CustomPropertySetter in one line
Declaration
protected void PropertySetter<T>(T value, Action<T> p, bool setIsDirty = true, bool raisePropertyChanged = true, bool raiseErrorsChanged = true, string propertyName = null)
Parameters
Type | Name | Description |
---|---|---|
T | value | Property value |
System.Action<T> | p | Action to execute when setting the property |
System.Boolean | setIsDirty | Whether to set the IsDirty flag to true |
System.Boolean | raisePropertyChanged | |
System.Boolean | raiseErrorsChanged | |
System.String | propertyName | Name of the property |
Type Parameters
Name | Description |
---|---|
T | Type of the property |
RaiseErrorsChanged(String, Object)
Execute validator and add error messages
Declaration
public virtual void RaiseErrorsChanged(string propertyName, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | Properties to handle errors of |
System.Object | value | Values to handle |
RaisePropertyChanged(String)
Raise event for a property which value has changed
Declaration
public void RaisePropertyChanged(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | Name of the Property |
RemoveValidator(String, Type)
Remove a validator of a specific type
Declaration
public void RemoveValidator(string propertyName, Type validatorType)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | Property name |
System.Type | validatorType | Validator type |
RemoveValidators(String)
Remove all validators for a specific property
Declaration
public void RemoveValidators(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | Name of the property to remove the validators from |
ValidateAll()
Validates without error
Declaration
public bool ValidateAll()
Returns
Type | Description |
---|---|
System.Boolean | Success |
ValidateAllProperties()
Validate all properties
Declaration
public void ValidateAllProperties()
ValidateAllProperties(IList<IValidateableViewModel>)
Validate all properties
Declaration
public void ValidateAllProperties(IList<IValidateableViewModel> validated)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IList<IValidateableViewModel> | validated |
Events
| Improve this Doc View SourceErrorsChanged
Declaration
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged
Event Type
Type | Description |
---|---|
System.EventHandler<System.ComponentModel.DataErrorsChangedEventArgs> |
PropertyChanged
Event which will be raised if a property has changed (Setter)
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type | Description |
---|---|
System.ComponentModel.PropertyChangedEventHandler |