How do i get the ElementReference for Radzen component

The library I am using has the following signature that includes the ElementReference of the input field. How do I get that from the RadzenTextBox component?

public static Task<Autocomplete> CreateAsync(IJSRuntime jsRuntime, ElementReference inputField, AutocompleteOptions opts = null);

The following line is failing: Cannot implicitly convert type 'Radzen.Blazor.RadzenTextBox' to 'Microsoft.AspNetCore.Components.ElementReference'

<RadzenTextBox style="width: 100%;" @ref="this.addressBox" Name="BusinessAddress1" value="@formattedAddress" />

You can use Element property of every Radzen component. Check this demo for reference:
https://blazor.radzen.com/tooltip

1 Like

In that example, the component is passing the element property on an event.

I need to get the element property during "OnAfterRenderAsync" to use with the method referenced in the question.

CreateAsync(JSRuntime, this.addressBox, new AutocompleteOptions

This code works with native HTML

<Input type="text" id="Address" @ref="this.addressBox" value="@formattedAddress"  />

References to native HTML elements are ElementReference, as I said in my previous reply you can use Element property of the Radzen component reference. For example:

<RadzenTextBox  @ref="textBox" ..
...
@code {
   RadzenTextBox  textBox;

   protected override Task OnAfterRenderAsync(bool firstRender)
   {
            var textBoxElement = textBox.Element;

            return base.OnAfterRenderAsync(firstRender);
   }
}

Thanks, that worked. exactly the info I needed.

This doesn't seem to work for RadzenTreeItem, is there a way to get the ElementReference for one of these?