Class MvvmComponentBase<TViewModel>
- Namespace
- Blazing.Mvvm.Components
- Assembly
- Blazing.Mvvm.dll
Provides a base Blazor component that resolves and manages a ViewModel of type TViewModel.
public abstract class MvvmComponentBase<TViewModel> : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IView<TViewModel>, IView, IDisposable where TViewModel : IViewModelBaseType Parameters
TViewModel-
The type of the ViewModel associated with this component.
Inheritance
Implements
Inherited Members
Properties
IsDisposed
Gets a value indicating whether the component has been disposed.
protected bool IsDisposed { get; }Property Value
ParameterResolver
Gets or sets the parameter resolver used to set parameters on the View and ViewModel.
[Inject]
protected IParameterResolver ParameterResolver { get; set; }Property Value
ViewModel
Gets or sets the ViewModel associated with this component, resolved from the dependency injection container.
protected virtual TViewModel ViewModel { get; set; }Property Value
- TViewModel
Methods
Dispose()
Disposes the component and releases resources.
public void Dispose()Dispose(bool)
Disposes the component and releases unmanaged resources.
protected virtual void Dispose(bool disposing)Parameters
OnAfterRender(bool)
Invoked after the component has rendered.
protected override void OnAfterRender(bool firstRender)Parameters
firstRenderbool-
True if this is the first time OnAfterRender(bool) is called; otherwise, false.
OnAfterRenderAsync(bool)
Asynchronously invoked after the component has rendered.
protected override Task OnAfterRenderAsync(bool firstRender)Parameters
firstRenderbool-
True if this is the first time OnAfterRenderAsync(bool) is called; otherwise, false.
Returns
OnInitialized()
Initializes the component and subscribes to ViewModel property changes.
protected override void OnInitialized()OnInitializedAsync()
Asynchronously initializes the component.
protected override Task OnInitializedAsync()Returns
OnParametersSet()
Sets parameters on the component and ViewModel.
protected override void OnParametersSet()OnParametersSetAsync()
Asynchronously sets parameters on the component and ViewModel.
protected override Task OnParametersSetAsync()Returns
SetParametersAsync(ParameterView)
Sets parameters from the given Microsoft.AspNetCore.Components.ParameterView on both the View and its ViewModel using the ParameterResolver
public override Task SetParametersAsync(ParameterView parameters)Parameters
parametersParameterView-
The parameters to set.
Returns
ShouldRender()
Determines whether the component should render.
protected override bool ShouldRender()Returns
- bool
-
trueif the component should render; otherwise,false.