❔ Blazor: How to have a component inside a component?
I was reading the mudBlazor documentation and I saw that they call a blazor element and inside that element, they call other elements.
I didnt know it was even possible and I have no idea how i can do something like that.
I would like to call a component and inside that one, call as much component (that is made to work inside the parent one obviously) as I want.
As an exemple, I would like to make a table but the number of columns in unknown before run time. Inside the table component, I would like to be able to call multiple element such as textbox or a combobox. Anyway, something like in the picture.
Link to the mudblazor component: https://mudblazor.com/components/treeview#basic
MudBlazor
MudBlazor - Blazor Component Library
Blazor Component Library based on Material Design. MudBlazor is easy to use and extend, especially for .NET devs because it uses almost no Javascript.
9 Replies
you create components and nest them? I'm not sure what your question is
oh you want something like this?
This would be componentA.razor
this would be componentB.razor
Exactly what i am trying to do!
It doesnt work here what i did:
so it doesnt display anything?
oh apparently it must be named ChildContent
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-7.0#child-content-render-fragments
ASP.NET Core Razor components
Learn how to create and use Razor components in Blazor apps, including guidance on Razor syntax, component naming, namespaces, and component parameters.
I forgot to send the error, my mistake. I will try that asap, thanks!!
would you be able to use the RowTemplate https://mudblazor.com/components/table#table-with-related-data which is already built in
Yeah! I see that blazor librairies have a lot to offer, but i'm trying to understand what is going on behind the scene before starting a project in blazor!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.