You should ensure that the EventCallback object has a delegate before you invoke the delegate, like this: if (OnSelected.HasDelegate) { OnSelected.InvokeAsync(this.DayOfWeek); }
Very nice! Just tried it here with a custom class for my event, and it only worked if it inherit from EventArgs Like: public class MyCustomEventData : EventArgs ...then using it like: [Parameter] public EventCallback OnArquivoEnviado { get; set; } /////// var mce = new MyCustomEventData() { ... } await OnArquivoEnviado.InvokeAsync(mce); //////// To Bind it: public void Enviado(MyCustomEventData d) { } // Hope this helps somebody.
Nice example! Was a huge help!
Nice tutorial...
by the way which fonts are u using for the visual studio code editor...its very nice
Demo projects are not compiled due to multiple errors...There is no method such as OnInit(). It should be OnInitializedAsync()
You should ensure that the EventCallback object has a delegate before you invoke the delegate, like this:
if (OnSelected.HasDelegate)
{
OnSelected.InvokeAsync(this.DayOfWeek);
}
I have never really worked with Event and Delegate, what's the purpose of if(OnSelected.HasDelegate) ?
The modern pattern can perform all this in one line: OnSelected?.Invoke(sender, args);
worx, thank you!
Very nice! Just tried it here with a custom class for my event, and it only worked if it inherit from EventArgs
Like:
public class MyCustomEventData : EventArgs
...then using it like:
[Parameter]
public EventCallback OnArquivoEnviado { get; set; }
///////
var mce = new MyCustomEventData() { ... }
await OnArquivoEnviado.InvokeAsync(mce);
////////
To Bind it:
public void Enviado(MyCustomEventData d)
{
}
// Hope this helps somebody.