C
C#17mo ago
Gyoce

❔ Blazor generic component "Type or namespace could not be found"

Hello, In my blazor app, i have a generic component (with the use of @typeparam T). I have a page which has the call to my component like so : <TableView T="MyClass" /> When i try to add @ref to that component to have the reference inside my code section like so :
<TableView T="MyClass" @ref="myTable" />
@code {
private TableView<MyClass> myTable;
}
<TableView T="MyClass" @ref="myTable" />
@code {
private TableView<MyClass> myTable;
}
It gives me an error "The type or namespace name 'TableView<>' could not be found (are you missing a using directive or an assembly reference?)" Which i don't understand because before adding the @ref it worked great ! PS: i tried to clean then build & rebuild entirely but nothing changed and of course i check all the using statements to include my custom generic component (which worked before adding the @ref on it)
2 Replies
Gyoce
GyoceOP17mo ago
It looks like you have to create a file name "TableView.razor.cs" and declare a public partial class TableView<T> in order to works which is kinda weird but ok
Accord
Accord17mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server