Class BaseViewModelMixin<TViewModel>
- Namespace
- Bannerlord.UIExtenderEx.ViewModels
- Assembly
- Bannerlord.UIExtenderEx.dll
Basic implementation for IViewModelMixin.
Generic parameter TViewModel will be used to determine which ViewModel to extend.
You can use the field ViewModel to access the original ViewModel.
Be aware that it might be null if GC has disposed the original ViewModel. The mixin holds a weak reference to it.
public abstract class BaseViewModelMixin<TViewModel> : IViewModelMixin where TViewModel : ViewModel
Type Parameters
TViewModelViewModel this mixin is extending.
- Inheritance
-
BaseViewModelMixin<TViewModel>
- Implements
- Inherited Members
Constructors
BaseViewModelMixin(TViewModel)
protected BaseViewModelMixin(TViewModel vm)
Parameters
vmTViewModel
Properties
ViewModel
The original ViewModel.
Be aware that it might be null if GC has disposed the original ViewModel. The mixin holds a weak reference to it.
protected TViewModel? ViewModel { get; }
Property Value
- TViewModel
Methods
GetPrivate<TValue>(string)
Helper method to get non public value from attached view model instance.
protected TValue? GetPrivate<TValue>(string name)
Parameters
namestringname of the field
Returns
- TValue
Type Parameters
TValuetype
OnFinalize()
Called when the original's OnFinalize() is called.
Defaults to an empty method.
public virtual void OnFinalize()
OnPropertyChanged(string?)
protected void OnPropertyChanged(string? propertyName = null)
Parameters
propertyNamestring
OnPropertyChangedWithValue(object, string?)
protected void OnPropertyChangedWithValue(object value, string? propertyName = null)
Parameters
OnRefresh()
Called when the original ViewModel is refreshed. The method name is dynamic, you need to set
RefreshMethodName for the method to be called.
Defaults to an empty method.
public virtual void OnRefresh()
SetField<T>(ref T, T, string)
protected bool SetField<T>(ref T field, T value, string propertyName)
Parameters
fieldTvalueTpropertyNamestring
Returns
Type Parameters
T
SetPrivate<TValue>(string, TValue?)
Helper method to set non public value of attached view model instance.
protected void SetPrivate<TValue>(string name, TValue? value)
Parameters
namestringname of the member to set
valueTValuenew value
Type Parameters
TValuemember type