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
TViewModel
ViewModel this mixin is extending.
- Inheritance
-
BaseViewModelMixin<TViewModel>
- Implements
- Inherited Members
Constructors
BaseViewModelMixin(TViewModel)
protected BaseViewModelMixin(TViewModel vm)
Parameters
vm
TViewModel
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
name
stringname of the field
Returns
- TValue
Type Parameters
TValue
type
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
propertyName
string
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
field
Tvalue
TpropertyName
string
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
name
stringname of the member to set
value
TValuenew value
Type Parameters
TValue
member type
This page was last modified at 07/29/2024 19:48:40 +03:00 (UTC).
Commit Message
Author: Vitalii Mikhailov
Commit: ee6db6e93e65682389fe6fd9c1d151945a0d7bf1
using new collection arrays