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 to this section

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 to this section

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 to this section

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 to this section

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 to this section

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 to this section

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.

DefaultUICultureLink to this section

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

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

ElementLink to this section

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 to this section

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 to this section

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 to this section

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 to this section

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 to this section

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 to this section

Gets or sets the inline CSS style.

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

UICultureLink to this section

Gets or sets the culture used for localized UI strings. If not set, uses the DefaultUICulture from a parent component or falls back to CurrentUICulture.

Declaration
public Globalization.CultureInfo UICulture { get; set; }
Property Value
Type Description
Globalization.CultureInfoGets or sets the culture used for localized UI strings. If not set, uses the DefaultUICulture from a parent component or falls back to CurrentUICulture.

UniqueIDLink to this section

Gets or sets the unique identifier.

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

VisibleLink to this section

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 to this section

Adds context menu for this component.

Declaration
protected virtual Task AddContextMenu()
Returns
Type Description
Task

DebounceLink to this section

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 to this section

Detaches event handlers and disposes Reference.

Declaration
public virtual void Dispose()

GetComponentCssClassLink to this section

Gets the component CSS class.

Declaration
protected virtual string GetComponentCssClass()
Returns
Type Description
string

GetCssClassLink to this section

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 to this section

Gets the unique identifier.

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

LocalizeLink to this section

Returns a localized string for the specified key using the current UICulture.

Declaration
public string Localize(string key)
Parameters
Type Name Description
string key The resource key. Use nameof(RadzenStrings.SomeKey) for compile-time safety.
Returns
Type Description
stringThe localized string.

OnAfterRenderAsyncLink to this section

Called by the Blazor runtime.

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

OnBecameInvisibleLink to this section

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 to this section

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 to this section

Called by the Blazor runtime.

Declaration
protected override void OnInitialized()

OnMouseEnterLink to this section

Raises MouseEnter.

Declaration
public Task OnMouseEnter()
Returns
Type Description
Task

OnMouseLeaveLink to this section

Raises MouseLeave.

Declaration
public Task OnMouseLeave()
Returns
Type Description
Task

RaiseContextMenuLink to this section

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 to this section

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

Declaration
public Task RaiseMouseEnter()
Returns
Type Description
Task

RaiseMouseLeaveLink to this section

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

Declaration
public Task RaiseMouseLeave()
Returns
Type Description
Task

SetParametersAsyncLink to this section

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 🗙