Table of Contents

Class ViewModelBase

Namespace
Blazing.Mvvm.ComponentModel
Assembly
Blazing.Mvvm.Base.dll

Provides a base class for ViewModels that implement CommunityToolkit.Mvvm.ComponentModel.ObservableObject, supporting property change notification and Blazor MVVM lifecycle methods. Implements IViewModelBase for integration with Blazor Views.

public abstract class ViewModelBase : ObservableObject, INotifyPropertyChanging, IViewModelBase, INotifyPropertyChanged, IDisposable

Inheritance

Implements

Inherited Members

Constructors

ViewModelBase()

Initializes a new instance of the ViewModelBase class and subscribes to command property changes.

protected ViewModelBase()

Methods

CommandPropertyChanged(object?, PropertyChangedEventArgs)

Handles property changes for subscribed CommunityToolkit.Mvvm.Input.IAsyncRelayCommand instances.

protected virtual void CommandPropertyChanged(object? sender, PropertyChangedEventArgs e)

Parameters

sender object?

The command that raised the event.

e PropertyChangedEventArgs

The event data.

Dispose(bool)

Releases the unmanaged resources used by the RecipientViewModelBase and optionally releases the managed resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

True to release both managed and unmanaged resources; false to release only unmanaged resources.

Dispose()

Disposes the ViewModel and releases resources.

public void Dispose()

NotifyStateChanged()

Notifies the View that its state has changed and a UI update may be required.

public virtual void NotifyStateChanged()

OnAfterRender(bool)

Invoked when the View has been rendered.

public virtual void OnAfterRender(bool firstRender)

Parameters

firstRender bool

Set to true if this is the first time the view is rendered; otherwise, false.

OnAfterRenderAsync(bool)

Asynchronously invoked when the View has been rendered.

public virtual Task OnAfterRenderAsync(bool firstRender)

Parameters

firstRender bool

Set to true if this is the first time the view is rendered; otherwise, false.

Returns

Task

A Task representing the asynchronous operation.

OnInitialized()

Invoked when the View is initialized and has received its initial parameters.

public virtual void OnInitialized()

OnInitializedAsync()

Asynchronously invoked when the View is initialized and has received its initial parameters.

public virtual Task OnInitializedAsync()

Returns

Task

A Task representing the asynchronous operation.

OnParametersSet()

Invoked when the View has received parameters from its parent and parameter values have been set.

public virtual void OnParametersSet()

OnParametersSetAsync()

Asynchronously invoked when the View has received parameters from its parent and parameter values have been set.

public virtual Task OnParametersSetAsync()

Returns

Task

A Task representing the asynchronous operation.

ShouldRender()

Determines whether the View should render.

public virtual bool ShouldRender()

Returns

bool

true if the View should render; otherwise, false.