Hello Team,
I already found out how to create a custom Razor Component based on a Radzen Component (Radzen Components from Razor Class Library ).
Still I didn’t get to do the same with the Radzen Services such as the NotificationService.
I first created regular c# classes as following (as I did with the basic Radzen Components):
public class MyNotification : RadzenNotification
public class MyNotificationService : NotificationService
Then I added <MyNotification />
in MainLayout.razor
and builder.Services.AddScoped<MyNotificationService>();
in Program.cs
.
But it didn’t work.
Some help would be great.
Thank you.
diegodiegoo:
But it didn’t work.
What doesn't work? What is supposed to work? It is unclear what the problem is and what you are trying to achieve.
I couldn’t show a notification (via a Button for example) based on my custom service with this code:
@inject MyNotificationService NotifService
NotifService.Notify(new NotificationMessage { Severity = NotificationSeverity.Warning, Summary = "Some Information!", Detail = "", Duration = 4000 });
It did work with the direct Radzen Service and Component.
You can try adding this as well. Not sure it would work but worth to try.
builder.Services.AddScoped<Radzen.NotificationService, MyNotificationService>()
To be honest I am not sure what you are trying to achieve here. I recommend checking the implementation of RadzenNotification.
Unfortunately, it didnt work.
I just dont want to directly use Radzen Components or Services.
The idea was to make custom components and services based on Radzen in a razor class library project.
I managed to do that with the normal components (MyLabel : RadzenLabel) but I couldnt find a solution for RadzenDialog, RadzenNotification, RadzenContextMenu and RadzenTooltip which are sort of special and related to services.