Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if EventCallback has been set Blazor

Tags:

blazor

Is there a way to check if EventCallback has been set to something. I am setting mine outside the component and only want to show certain things inside the component if the EventCallback has been set.

like image 257
americanslon Avatar asked Jan 24 '20 20:01

americanslon


1 Answers

You can use the HasDelegate property on the EventCallback parameter. This will return a bool indicating whether the event dispatcher is non null

[Parameter]
public EventCallback DoSomething { get; set; }

private bool IsEventSet => DoSomething.HasDelegate;
like image 150
Rob Avatar answered Oct 18 '22 14:10

Rob