Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 3953

Is there a way to programmatically bind an event to a method in Blazor?

$
0
0

While the normal way of event binding is by using attributes in the markup, I'd like to automatically event bind. This would be great when there is a large number of instances the component. In my case I'd like to always call a CascadingParameter component in the OnClick the same way.

Something like this:

public class PrositThBase : ComponentBase{    [Parameter]    public RenderFragment ChildContent { get; set; }    protected override async Task OnInitializedAsync()    {        OnClick += OnClick;        base.OnInitializedAsync();    }    public void OnClick()    {    }}

But this does not work. Is there any way of accomplishing this?


Viewing all articles
Browse latest Browse all 3953

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>