I am trying to use the notifcation component in my Blazor app and cannot get it to work. My startup is thus:
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<NotificationService>();
}
public void Configure(IComponentsApplicationBuilder app)
{
app.AddComponent<App>("app");
}
}
and my page is thus:
@inject IJSRuntime jsRuntime
@inject NotificationService notificationService
@inject DialogService dialogService
@page "/"
<RadzenCard>
<h3 style="margin-top: 40px">Calendar</h3>
<RadzenButton Text=@($"Show success notification") Style="margin-bottom: 20px; width: 200px"
Click="@(args => ShowNotification(new NotificationMessage() { Severity = NotificationSeverity.Success, Summary = "Success Summary", Detail = "Success Detail", Duration = 4000 }))" />
<RadzenDatePicker Inline="true" Change="@(args => Change(args, "Calendar", "MM/dd/yyyy"))" />
</RadzenCard>
@code{
Dictionary<DateTime, string> events = new Dictionary<DateTime, string>();
protected async void ConnectUsb()
{
await jsRuntime.InvokeAsync<bool>("connectUsb");
}
async void ShowNotification(NotificationMessage message)
{
notificationService.Notify(message);
events.Add(DateTime.Now, $"{message.Severity} notification");
await InvokeAsync(() => { StateHasChanged(); });
}
void Change(DateTime? value, string name, string format)
{
//events.Add(DateTime.Now, $"{name} value changed to {value?.ToString(format)}");
//StateHasChanged();
}
}
What am I missing? The ShowNotification get called, but no notification get popped up.
Thanks