Table of Contents

Class MvvmLayoutComponentBase<TViewModel>

Namespace
Blazing.Mvvm.Components
Assembly
Blazing.Mvvm.dll

A base class for components that represent a layout and resolves a ViewModel of type TViewModel.

public abstract class MvvmLayoutComponentBase<TViewModel> : LayoutComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IView<TViewModel>, IView, IDisposable where TViewModel : IViewModelBase

Type Parameters

TViewModel

The ViewModel.

Inheritance

Implements

Inherited Members

Properties

IsDisposed

Indicates if the component has been disposed.

protected bool IsDisposed { get; }

Property Value

bool

ParameterResolver

Resolves parameters in the View and ViewModel.

[Inject]
protected IParameterResolver ParameterResolver { get; set; }

Property Value

IParameterResolver

ViewModel

The ViewModel associated with this component, resolved from the dependency injection container.

protected virtual TViewModel ViewModel { get; set; }

Property Value

TViewModel

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

Disposes the component and releases unmanaged resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

A boolean value indicating whether the method was called from the dispose method or from a finalizer.

OnAfterRender(bool)

Method invoked after each time the component has rendered interactively and the UI has finished updating (for example, after elements have been added to the browser DOM). Any Microsoft.AspNetCore.Components.ElementReference fields will be populated by the time this runs.

This method is not invoked during prerendering or server-side rendering, because those processes are not attached to any live browser DOM and are already complete before the DOM is updated.

protected override void OnAfterRender(bool firstRender)

Parameters

firstRender bool

Set to true if this is the first time Microsoft.AspNetCore.Components.ComponentBase.OnAfterRender(System.Boolean) has been invoked on this component instance; otherwise false.

Remarks

The Microsoft.AspNetCore.Components.ComponentBase.OnAfterRender(System.Boolean) and Microsoft.AspNetCore.Components.ComponentBase.OnAfterRenderAsync(System.Boolean) lifecycle methods are useful for performing interop, or interacting with values received from @ref. Use the firstRender parameter to ensure that initialization work is only performed once.

OnAfterRenderAsync(bool)

Method invoked after each time the component has been rendered interactively and the UI has finished updating (for example, after elements have been added to the browser DOM). Any Microsoft.AspNetCore.Components.ElementReference fields will be populated by the time this runs.

This method is not invoked during prerendering or server-side rendering, because those processes are not attached to any live browser DOM and are already complete before the DOM is updated.

Note that the component does not automatically re-render after the completion of any returned Task, because that would cause an infinite render loop.

protected override Task OnAfterRenderAsync(bool firstRender)

Parameters

firstRender bool

Set to true if this is the first time Microsoft.AspNetCore.Components.ComponentBase.OnAfterRender(System.Boolean) has been invoked on this component instance; otherwise false.

Returns

Task

A Task representing any asynchronous operation.

Remarks

The Microsoft.AspNetCore.Components.ComponentBase.OnAfterRender(System.Boolean) and Microsoft.AspNetCore.Components.ComponentBase.OnAfterRenderAsync(System.Boolean) lifecycle methods are useful for performing interop, or interacting with values received from @ref. Use the firstRender parameter to ensure that initialization work is only performed once.

OnInitialized()

Method invoked when the component is ready to start, having received its initial parameters from its parent in the render tree.

protected override void OnInitialized()

OnInitializedAsync()

Method invoked when the component is ready to start, having received its initial parameters from its parent in the render tree.

Override this method if you will perform an asynchronous operation and want the component to refresh when that operation is completed.

protected override Task OnInitializedAsync()

Returns

Task

A Task representing any asynchronous operation.

OnParametersSet()

Method invoked when the component has received parameters from its parent in the render tree, and the incoming values have been assigned to properties.

protected override void OnParametersSet()

OnParametersSetAsync()

Method invoked when the component has received parameters from its parent in the render tree, and the incoming values have been assigned to properties.

protected override Task OnParametersSetAsync()

Returns

Task

A Task representing any asynchronous operation.

SetParametersAsync(ParameterView)

Sets parameters supplied by the component's parent in the render tree.

public override Task SetParametersAsync(ParameterView parameters)

Parameters

parameters ParameterView

The parameters.

Returns

Task

A Task that completes when the component has finished updating and rendering itself.

Remarks

Parameters are passed when Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync(Microsoft.AspNetCore.Components.ParameterView) is called. It is not required that the caller supply a parameter value for all of the parameters that are logically understood by the component.

The default implementation of Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync(Microsoft.AspNetCore.Components.ParameterView) will set the value of each property decorated with Microsoft.AspNetCore.Components.ParameterAttribute or Microsoft.AspNetCore.Components.CascadingParameterAttribute that has a corresponding value in the Microsoft.AspNetCore.Components.ParameterView. Parameters that do not have a corresponding value will be unchanged.

ShouldRender()

Returns a flag to indicate whether the component should render.

protected override bool ShouldRender()

Returns

bool