Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Use a @typeparam as component in Blazor

$
0
0

Is it possible to use a @typeparam as Component?More explicitly, do something like the following MyComponent.razor:

@typeparam TComponent<TComponent />

Of course, there would also be a MyComponent.razor.cs file whose content would be:

public partial MyComponent<TComponent> : ComponentBase where TComponent : ComponentBase

so that the compiler would know that <TComponent /> is meaningful.

I cannot find any documentation about this in Microsoft docs.

When I try it seems to compile, but display the following warning:

warning RZ10012: Found markup element with unexpected name 'TComponent'. If this is intended to be a component, add a @using directive for its namespace

However it is only a warning and not an error. It does't show anything in the browser though.

I am using ASP.NET 5.

Thanks


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>