I would like to create my own components in a razor class library, based on Radzen.
Assuming I have a MyLabel.razor with simply one RadzenLabel.
To access to all the properties and methods of the RadzenLabel, I have to explicitly declare them all as Parameters.
<RadzenLabel Text="@Text"></RadzenLabel>
@code
{
[Parameter]
public string Text { get; set; } = "";
}
Not sure what you’ve tried with @inherits however I can assure you that definitely works. You can check our source code for reference. Not sure about @ref however how it’s related.
If you use composition over inheritance indeed you will need to declare all properties/methods in your custom component.
I think I get it now.
Using simply the RadzenLabel with @inherits RadzenLabel isnt enough.
Also you dont need to declare the parameters explicitly - as I did before -. Just use @inherits RadzenLabel.
Still you need at least to assign the parameters to each other like Text ="@Text".
I think it doesnt get any better. If if does please let me know.
Thank you
Inheritance won't work if you use a .razor file. In that case it will override the default rendering of the component and you would need to specify your own properties. However if you create a regular c# class which inherits from RadzenLabel you would inherit the rendering too.
It does get better. Thank you very much
Could I do the same with the NotificationService for example?
I didnt get it to work with the following code: public class MyNotification : RadzenNotification public class MyNotificationService : NotificationService
In MainLayout.razor I first added both Elements <MyNotification /> and <RadzenNotification /> for test purposes.
Same in Program.cs with builder.Services.AddScoped<NotificationService>(); and builder.Services.AddScoped<MyNotificationService>();
Only the RadzenService works fine.
So the question is generally how can I make a custom service out of a Radzen Service.
Thank you.
Ex: I need to achive a component that has the input form in question as child of the New RadzenFormField Component. So for example by calling CustomInputText i result with a RadzenInputText inside a RadzenFormField. (the example dont need to be related to this scenario)