RadzenComponent Class

Base class for all Radzen Blazor components providing common functionality for styling, attributes, events, and lifecycle management. All Radzen components inherit from RadzenComponent to gain standard features like visibility control, custom attributes, mouse events, and disposal. Provides foundational functionality including visibility control via Visible property, custom CSS via Style property and class via Attributes, HTML attribute passing via unmatched parameters, MouseEnter/MouseLeave/ContextMenu event callbacks, localization support for numbers/dates/text, access to the rendered HTML element via Element Reference, and proper cleanup via IDisposable pattern. Components inheriting from RadzenComponent can override GetComponentCssClass() to provide their base CSS classes and use the protected Visible property to control rendering.

Implements

IComponent

IHandleEvent

IHandleAfterRender

Inherited Members

ComponentBase.BuildRenderTree

ComponentBase.OnInitializedAsync

ComponentBase.OnParametersSet

ComponentBase.OnParametersSetAsync

ComponentBase.StateHasChanged

ComponentBase.ShouldRender

ComponentBase.OnAfterRender

ComponentBase.InvokeAsync

ComponentBase.DispatchExceptionAsync

ComponentBase.RendererInfo

ComponentBase.Assets

ComponentBase.AssignedRenderMode

Namespace: Radzen

Assembly: Radzen.Blazor.dll

Syntax

public class RadzenComponent : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender

Constructors

RadzenComponentlink

Base class for all Radzen Blazor components providing common functionality for styling, attributes, events, and lifecycle management. All Radzen components inherit from RadzenComponent to gain standard features like visibility control, custom attributes, mouse events, and disposal. Provides foundational functionality including visibility control via Visible property, custom CSS via Style property and class via Attributes, HTML attribute passing via unmatched parameters, MouseEnter/MouseLeave/ContextMenu event callbacks, localization support for numbers/dates/text, access to the rendered HTML element via Element Reference, and proper cleanup via IDisposable pattern. Components inheriting from RadzenComponent can override GetComponentCssClass() to provide their base CSS classes and use the protected Visible property to control rendering.

Declaration
public RadzenComponent()

Properties

Attributeslink

Gets or sets a dictionary of additional HTML attributes that will be applied to the component's root element. Any attributes not explicitly defined as parameters will be captured here and rendered on the element. Use this to add data-* attributes, ARIA attributes, or any custom HTML attributes.

Declaration
public IReadOnlyDictionary<string, object> Attributes { get; set; }
Property Value
Type Description
IReadOnlyDictionary<string, object>Gets or sets a dictionary of additional HTML attributes that will be applied to the component's root element. Any attributes not explicitly defined as parameters will be captured here and rendered on the element. Use this to add data-* attributes, ARIA attributes, or any custom HTML attributes.

ContextMenulink

Gets or sets the callback invoked when the user right-clicks the component. Commonly used with ContextMenuService to display context menus. Receives mouse event arguments containing click position.

Declaration
public EventCallback<MouseEventArgs> ContextMenu { get; set; }
Property Value
Type Description
EventCallback<MouseEventArgs>Gets or sets the callback invoked when the user right-clicks the component. Commonly used with ContextMenuService to display context menus. Receives mouse event arguments containing click position.

Culturelink

Gets or sets the culture used for formatting and parsing localizable data (numbers, dates, currency). If not set, uses the DefaultCulture from a parent component or falls back to CurrentCulture.

Declaration
public Globalization.CultureInfo Culture { get; set; }
Property Value
Type Description
Globalization.CultureInfoGets or sets the culture used for formatting and parsing localizable data (numbers, dates, currency). If not set, uses the DefaultCulture from a parent component or falls back to CurrentCulture.

CurrentStylelink

Gets the current style as a dictionary.

Declaration
protected IDictionary<string, string> CurrentStyle { get; }
Property Value
Type Description
IDictionary<string, string>Gets the current style as a dictionary.

DefaultCulturelink

Gets or sets the default culture cascaded from a parent component. This allows setting a culture at the layout level that applies to all child Radzen components. Child components can override this by setting their own Culture property.

Declaration
public Globalization.CultureInfo DefaultCulture { get; set; }
Property Value
Type Description
Globalization.CultureInfoGets or sets the default culture cascaded from a parent component. This allows setting a culture at the layout level that applies to all child Radzen components. Child components can override this by setting their own Culture property.

Elementlink

Gets a reference to the HTML element rendered by this component. Can be used with JavaScript interop or for programmatic DOM manipulation. The reference is only valid after the component has been rendered (after OnAfterRender).

Declaration
public ElementReference Element { get; set; }
Property Value
Type Description
ElementReferenceGets a reference to the HTML element rendered by this component. Can be used with JavaScript interop or for programmatic DOM manipulation. The reference is only valid after the component has been rendered (after OnAfterRender).

IsJSRuntimeAvailablelink

Gets or sets a value indicating whether JSRuntime is available.

Declaration
protected bool IsJSRuntimeAvailable { get; set; }
Property Value
Type Description
boolGets or sets a value indicating whether JSRuntime is available.

JSRuntimelink

Gets or sets the js runtime.

Declaration
protected Microsoft.JSInterop.IJSRuntime JSRuntime { get; set; }
Property Value
Type Description
Microsoft.JSInterop.IJSRuntimeGets or sets the js runtime.

MouseEnterlink

Gets or sets the callback invoked when the mouse pointer enters the component's bounds. Commonly used with TooltipService to display tooltips on hover. Receives the component's ElementReference as a parameter.

Declaration
public EventCallback<ElementReference> MouseEnter { get; set; }
Property Value
Type Description
EventCallback<ElementReference>Gets or sets the callback invoked when the mouse pointer enters the component's bounds. Commonly used with TooltipService to display tooltips on hover. Receives the component's ElementReference as a parameter.

MouseLeavelink

Gets or sets the callback invoked when the mouse pointer leaves the component's bounds. Commonly used with TooltipService to hide tooltips when hover ends. Receives the component's ElementReference as a parameter.

Declaration
public EventCallback<ElementReference> MouseLeave { get; set; }
Property Value
Type Description
EventCallback<ElementReference>Gets or sets the callback invoked when the mouse pointer leaves the component's bounds. Commonly used with TooltipService to hide tooltips when hover ends. Receives the component's ElementReference as a parameter.

Referencelink

Gets the reference for the current component.

Declaration
protected Microsoft.JSInterop.DotNetObjectReference<RadzenComponent> Reference { get; }
Property Value
Type Description
Microsoft.JSInterop.DotNetObjectReference<RadzenComponent>Gets the reference for the current component.

Stylelink

Gets or sets the inline CSS style.

Declaration
public string Style { get; set; }
Property Value
Type Description
stringGets or sets the inline CSS style.

UniqueIDlink

Gets or sets the unique identifier.

Declaration
public string UniqueID { get; set; }
Property Value
Type Description
stringGets or sets the unique identifier.

Visiblelink

Gets or sets a value indicating whether this RadzenComponent is visible. Invisible components are not rendered.

Declaration
public bool Visible { get; set; }
Property Value
Type Description
boolGets or sets a value indicating whether this RadzenComponent is visible. Invisible components are not rendered.

Methods

AddContextMenulink

Adds context menu for this component.

Declaration
protected virtual Task AddContextMenu()
Returns
Type Description
Task

Debouncelink

Debounces the specified action.

Declaration
protected void Debounce(Func<Task> action, int milliseconds)
Parameters
Type Name Description
Func<Task> action The action.
int milliseconds The milliseconds.

Disposelink

Detaches event handlers and disposes Reference.

Declaration
public virtual void Dispose()

GetComponentCssClasslink

Gets the component CSS class.

Declaration
protected virtual string GetComponentCssClass()
Returns
Type Description
string

GetCssClasslink

Gets the final CSS class rendered by the component. Combines it with a class custom attribute.

Declaration
protected string GetCssClass()
Returns
Type Description
string

GetIdlink

Gets the unique identifier.

Declaration
protected virtual string GetId()
Returns
Type Description
stringReturns the id attribute (if specified) or generates a random one.

OnAfterRenderAsynclink

Called by the Blazor runtime.

Declaration
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
Type Name Description
bool firstRender
Returns
Type Description
Task

OnBecameInvisiblelink

Called when the component becomes invisible. Cleans up JS interop resources without full disposal so the component can become visible again.

Declaration
protected virtual void OnBecameInvisible()

OnContextMenulink

Raises ContextMenu.

Declaration
public virtual Task OnContextMenu(MouseEventArgs args)
Parameters
Type Name Description
MouseEventArgs args The MouseEventArgs instance containing the event data.
Returns
Type Description
Task

OnInitializedlink

Called by the Blazor runtime.

Declaration
protected override void OnInitialized()

OnMouseEnterlink

Raises MouseEnter.

Declaration
public Task OnMouseEnter()
Returns
Type Description
Task

OnMouseLeavelink

Raises MouseLeave.

Declaration
public Task OnMouseLeave()
Returns
Type Description
Task

RaiseContextMenulink

Invoked via interop when the browser "oncontextmenu" event is raised for this component.

Declaration
public Task RaiseContextMenu(MouseEventArgs e)
Parameters
Type Name Description
MouseEventArgs e The MouseEventArgs instance containing the event data.
Returns
Type Description
Task

RaiseMouseEnterlink

Invoked via interop when the browser "onmouseenter" event is raised for this component.

Declaration
public Task RaiseMouseEnter()
Returns
Type Description
Task

RaiseMouseLeavelink

Invoked via interop when the browser "onmouseleave" event is raised for this component.

Declaration
public Task RaiseMouseLeave()
Returns
Type Description
Task

SetParametersAsynclink

Called by the Blazor runtime when parameters are set.

Declaration
public override Task SetParametersAsync(ParameterView parameters)
Parameters
Type Name Description
ParameterView parameters The parameters.
Returns
Type Description
Task
An error has occurred. This app may no longer respond until reloaded. Reload 🗙