"Wrapping" or "encasing" a Radzen component

I created a custom Razor element that wraps a RadzenDropdown list in it.

I have also implemented an Action for SelectedItemChanged(), which works well. The problem is that the dropdown doesn't refresh. I had to click on the dropdown immediately after I selected an item to get the value displayed.

Any idea what I missed? Thanks!

You might need to execute StateHasChanged() for your component.

You also said you implemented an Action for the event. You probably need to use EventCallback instead.

Hi, probably a stupid question, but what is the rational to use Action<> instead of EventCallback in the radzen code?

/// <summary>
        /// Gets or sets the selected item changed.
        /// </summary>
        /// <value>The selected item changed.</value>
        [Parameter]
        public Action<object> SelectedItemChanged { get; set; }

EventCallback causes the component to render again. For some events that we fire during rendering using EventCallback would lead to an endless loop.

2 Likes