Class RadzenComponent
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.
Inheritance
Inherited Members
Namespace: Radzen
Assembly: Radzen.Blazor.dll
Syntax
public class RadzenComponent : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
Constructors
RadzenComponent()
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
Attributes
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
[Parameter(CaptureUnmatchedValues = true)]
public IReadOnlyDictionary<string, object> Attributes { get; set; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, object> | The unmatched attributes dictionary. |
ContextMenu
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
[Parameter]
public EventCallback<MouseEventArgs> ContextMenu { get; set; }
Property Value
| Type | Description |
|---|---|
| EventCallback<MouseEventArgs> | The context menu (right-click) event callback. |
Culture
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
[Parameter]
public CultureInfo Culture { get; set; }
Property Value
| Type | Description |
|---|---|
| CultureInfo | The culture for localization. Default is CurrentCulture. |
CurrentStyle
Gets the current style as a dictionary.
Declaration
protected IDictionary<string, string> CurrentStyle { get; }
Property Value
| Type | Description |
|---|---|
| IDictionary<string, string> | The current style as a dictionary of keys and values. |
DefaultCulture
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
[CascadingParameter(Name = "DefaultCulture")]
public CultureInfo DefaultCulture { get; set; }
Property Value
| Type | Description |
|---|---|
| CultureInfo | The cascaded default culture. |
Element
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; protected set; }
Property Value
| Type | Description |
|---|---|
| ElementReference | The element reference to the rendered HTML element. |
IsJSRuntimeAvailable
Gets or sets a value indicating whether JSRuntime is available.
Declaration
protected bool IsJSRuntimeAvailable { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
JSRuntime
Gets or sets the js runtime.
Declaration
[Inject]
protected IJSRuntime JSRuntime { get; set; }
Property Value
| Type | Description |
|---|---|
| IJSRuntime | The js runtime. |
MouseEnter
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
[Parameter]
public EventCallback<ElementReference> MouseEnter { get; set; }
Property Value
| Type | Description |
|---|---|
| EventCallback<ElementReference> | The mouse enter event callback. |
MouseLeave
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
[Parameter]
public EventCallback<ElementReference> MouseLeave { get; set; }
Property Value
| Type | Description |
|---|---|
| EventCallback<ElementReference> | The mouse leave event callback. |
Reference
Gets the reference for the current component.
Declaration
protected DotNetObjectReference<RadzenComponent> Reference { get; }
Property Value
| Type | Description |
|---|---|
| DotNetObjectReference<RadzenComponent> | The reference. |
Style
Gets or sets the inline CSS style.
Declaration
[Parameter]
public virtual string Style { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The style. |
UniqueID
Gets or sets the unique identifier.
Declaration
public string UniqueID { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The unique identifier. |
Visible
Gets or sets a value indicating whether this RadzenComponent is visible. Invisible components are not rendered.
Declaration
[Parameter]
public virtual bool Visible { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Methods
AddContextMenu()
Adds context menu for this component.
Declaration
protected virtual Task AddContextMenu()
Returns
| Type | Description |
|---|---|
| Task |
Debounce(Func<Task>, int)
Debounces the specified action.
Declaration
protected void Debounce(Func<Task> action, int milliseconds = 500)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task> | action | The action. |
| int | milliseconds | The milliseconds. |
Dispose()
Detaches event handlers and disposes Reference.
Declaration
public virtual void Dispose()
GetComponentCssClass()
Gets the component CSS class.
Declaration
protected virtual string GetComponentCssClass()
Returns
| Type | Description |
|---|---|
| string |
GetCssClass()
Gets the final CSS class rendered by the component. Combines it with a class custom attribute.
Declaration
protected string GetCssClass()
Returns
| Type | Description |
|---|---|
| string |
GetId()
Gets the unique identifier.
Declaration
protected virtual string GetId()
Returns
| Type | Description |
|---|---|
| string | Returns the |
OnAfterRenderAsync(bool)
Called by the Blazor runtime.
Declaration
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | firstRender |
Returns
| Type | Description |
|---|---|
| Task |
Overrides
OnContextMenu(MouseEventArgs)
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 |
OnInitialized()
Called by the Blazor runtime.
Declaration
protected override void OnInitialized()
Overrides
OnMouseEnter()
Raises MouseEnter.
Declaration
public Task OnMouseEnter()
Returns
| Type | Description |
|---|---|
| Task |
OnMouseLeave()
Raises MouseLeave.
Declaration
public Task OnMouseLeave()
Returns
| Type | Description |
|---|---|
| Task |
RaiseContextMenu(MouseEventArgs)
Invoked via interop when the browser "oncontextmenu" event is raised for this component.
Declaration
[JSInvokable("RadzenComponent.RaiseContextMenu")]
public Task RaiseContextMenu(MouseEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseEventArgs | e | The MouseEventArgs instance containing the event data. |
Returns
| Type | Description |
|---|---|
| Task |
RaiseMouseEnter()
Invoked via interop when the browser "onmouseenter" event is raised for this component.
Declaration
[JSInvokable("RadzenComponent.RaiseMouseEnter")]
public Task RaiseMouseEnter()
Returns
| Type | Description |
|---|---|
| Task |
RaiseMouseLeave()
Invoked via interop when the browser "onmouseleave" event is raised for this component.
Declaration
[JSInvokable("RadzenComponent.RaiseMouseLeave")]
public Task RaiseMouseLeave()
Returns
| Type | Description |
|---|---|
| Task |
SetParametersAsync(ParameterView)
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 |