Table of Contents

Class MvvmNavLinkBase

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

Provides a base class for MVVM-aware navigation link components in Blazor that can navigate to a specified URI and reflect active state.

public abstract class MvvmNavLinkBase : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable

Inheritance

Derived

Implements

Inherited Members

Remarks

This class supports custom navigation logic, active state CSS, and integration with both Blazor's NavigationManager and MVVM navigation manager.

Properties

ActiveClass

Gets or sets the CSS class name applied to the NavLink when the current route matches the NavLink href.

[Parameter]
public string? ActiveClass { get; set; }

Property Value

string?

AdditionalAttributes

Gets or sets a collection of additional attributes that will be added to the generated a element.

[Parameter(CaptureUnmatchedValues = true)]
public IDictionary<string, object>? AdditionalAttributes { get; set; }

Property Value

IDictionary<string, object>?

ChildContent

Gets or sets the child content to be rendered inside the NavLink.

[Parameter]
public RenderFragment? ChildContent { get; set; }

Property Value

RenderFragment?

Match

Gets or sets a value representing the URL matching behavior for determining active state.

[Parameter]
public NavLinkMatch Match { get; set; }

Property Value

NavLinkMatch

MvvmNavigationManager

Gets or sets the MVVM navigation manager used by the NavLink for ViewModel-based navigation.

[Inject]
protected IMvvmNavigationManager MvvmNavigationManager { get; set; }

Property Value

IMvvmNavigationManager

NavigationManager

Gets or sets the Blazor navigation manager used by the NavLink for URI-based navigation.

[Inject]
protected NavigationManager NavigationManager { get; set; }

Property Value

NavigationManager

RelativeUri

Gets or sets the relative URI or query string to append to the associated URI.

[Parameter]
public string? RelativeUri { get; set; }

Property Value

string?

Methods

BuildRenderTree(RenderTreeBuilder)

Builds the render tree for the NavLink component.

protected override void BuildRenderTree(RenderTreeBuilder builder)

Parameters

builder RenderTreeBuilder

The Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder used to build the render tree.

Dispose()

Releases resources used by the component.

public void Dispose()

Dispose(bool)

Releases resources used by the component and unsubscribes from events.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

True if called from Dispose(); false if called from a finalizer.

OnInitialized()

Called when the component is initialized. Subscribes to location change events.

protected override void OnInitialized()

OnParametersSet()

Called when component parameters are set. Updates href, active state, and CSS class.

protected override void OnParametersSet()

ResolveHref()

Resolves the href for the NavLink. Must be implemented by derived classes.

protected abstract string ResolveHref()

Returns

string

The resolved href string.