Table of Contents

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

TViewModel

The ViewModel type this mixin extends.

Inheritance
BaseViewModelMixin<TViewModel>
Implements
Inherited Members

Constructors

BaseViewModelMixin(TViewModel)

protected BaseViewModelMixin(TViewModel vm)

Parameters

vm TViewModel

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

name string

The 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

TValue

The 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

propertyName string

OnPropertyChangedWithValue(object, string?)

protected void OnPropertyChangedWithValue(object value, string? propertyName = null)

Parameters

value object
propertyName string

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

propertyName string

The 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

field T

A reference to the backing field.

value T

The new value to assign.

propertyName string

The name of the property for change notification.

Returns

bool

true if the value was modified; otherwise, false.

Type Parameters

T

The 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

name string

The name of the private field or property.

value TValue

The value to assign.

Type Parameters

TValue

The 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