Inject notification service error

Very much a newbie here, so apologies in advance if this is obvious!

I have some of the other Radzen UI components working fine however, when I come to work with say the notification service, I seem to be getting an error with the @Inject line:

@page "/"
@using Radzen.Blazor

**@inject NotificationService notificationService**
    

<h1>Hello, world! from Blazor</h1>

Welcome to your new Blazor app.

<SurveyPrompt Title="How is Blazor working for you????" />

<RadzenButton Text=@($"Show success notification") Style="margin-bottom: 20px; width: 200px"
              Click="@(args => ShowNotification(new NotificationMessage() { Severity = "success", Summary = "Success Summary", Detail = "Success Detail", Duration = 4000 }))" />

@code {
    Dictionary<DateTime, string> events = new Dictionary<DateTime, string>();

    void ShowNotification(NotificationMessage message)
    {
        notificationService.Notify(message);

        events.Add(DateTime.Now, $"{message.Severity} notification");
        Invoke(() => { StateHasChanged(); });
    }
}

The error seems to suggest the service hasn't been added.. although I checked the github repo and checked for the startup.cs to see if there was the usual dependency injection "services.add" but couldn't see that?

I have to say, I am using .NET core 3 preview 7 with the latest Blazor templates and generated a "full stack" project, so perhaps I am a little too far ahead of the demos so far?

Many thanks in advance.

Hi @dsheardown,

You need to configure it in your Startup.cs file like this:

services.AddScoped<NotificationService>();

Here is how it is done in our demo application: https://github.com/akorchev/blazor.radzen.com/blob/master/Startup.cs#L34-L35

Excellent! thanks so much.