Class BaseViewModelMixin<TViewModel>
- Namespace
- Bannerlord.UIExtenderEx.ViewModels
- Assembly
- Bannerlord.UIExtenderEx.dll
Provides the base implementation for IViewModelMixin extending a target ViewModel.
Generic type parameter TViewModel designates the target host ViewModel type.
Access the underlying host instance via the protected ViewModel property, which maintains a weak reference
to avoid cyclic references and permit garbage collection.
public abstract class BaseViewModelMixin<TViewModel> : IViewModelMixin where TViewModel : ViewModel
Type Parameters
TViewModelThe ViewModel type this mixin extends.
- Inheritance
-
BaseViewModelMixin<TViewModel>
- Implements
- Inherited Members
Constructors
BaseViewModelMixin(TViewModel)
protected BaseViewModelMixin(TViewModel vm)
Parameters
vmTViewModel
Properties
ViewModel
Gets the attached host TViewModel instance, or null if the instance
has been garbage-collected.
protected TViewModel? ViewModel { get; }
Property Value
- TViewModel
Methods
GetPrivate<TValue>(string)
Retrieves a private or internal field or property value from the attached host ViewModel instance.
protected TValue? GetPrivate<TValue>(string name)
Parameters
namestringThe name of the private field or property.
Returns
- TValue
The member value, or default if the member cannot be resolved or the host instance is unavailable.
Type Parameters
TValueThe expected value type.
OnFinalize()
Invoked when the host ViewModel executes OnFinalize(), providing an opportunity for cleanup and resource disposal.
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()
Invoked when the host ViewModel executes its designated refresh method (configured via RefreshMethodName).
public virtual void OnRefresh()
OnViewModelPropertyChanged(string)
Invoked whenever the attached host ViewModel raises any property change notification (including standard and typed overloads).
TaleWorlds ViewModels dispatch most property updates through typed OnPropertyChangedWithValue overloads that
bypass standard PropertyChanged handlers. Overriding this method listens to all nine notification variants.
Subscriptions are registered after host construction and detached when the host ViewModel is finalized.
protected virtual void OnViewModelPropertyChanged(string propertyName)
Parameters
propertyNamestringThe name of the property that changed.
SetField<T>(ref T, T, string)
Assigns a new value to a backing field and raises property change notifications if the value changed.
protected bool SetField<T>(ref T field, T value, string propertyName)
Parameters
fieldTA reference to the backing field.
valueTThe new value to assign.
propertyNamestringThe name of the property for change notification.
Returns
Type Parameters
TThe field value type.
SetPrivate<TValue>(string, TValue?)
Sets a private or internal field or property value on the attached host ViewModel instance.
protected void SetPrivate<TValue>(string name, TValue? value)
Parameters
namestringThe name of the private field or property.
valueTValueThe value to assign.
Type Parameters
TValueThe value type.
This page was last modified at 10/06/2026 09:49:13 +03:00 (UTC).
Commit Message
Author: Vitalii Mikhailov
Commit: 6cc114e5698a26b1c33a1a0b5424e80e7c2a0cf8
Fix