MudBlazor:"CategoryTypes.Element":静态类型不能用作类型参数



我试图实现一个与MudBlazor组件库分组的MudTable。根据文档,您必须像这样定义组定义:

@code { 
private TableGroupDefinition<Element> _groupDefinition = new()
{
GroupName = "Group",
Indentation = false,
Expandable = true,
IsInitiallyExpanded = false,
Selector = (e) => e.Group
};
}

在组件中像这样使用:

<MudTable Items="@Elements"
...
GroupBy="@_groupDefinition">

但是我得到以下错误:

On_groupDefinitionCS0718: CategoryTypes.Element: static types cannot be used as type arguments

On(e)CS0721: CategoryTypes.Element: static types cannot be used as parameters

我知道静态类不能被实例化,因此错误是有意义的,但是开发人员是如何得到这个编译?

我使用。net 6, Blazor Webassembly和MudBlazor v6.0.10。

正如Jesse Good所评论的那样,我被一个Element类的例子所抓住,这个类也存在于MudBlazor库中,作为一个静态类!我用自己的类替换了这个类,即:

private TableGroupDefinition<Subcategory> _groupDefinition = new()
{
GroupName = "Category",
Indentation = false,
Expandable = true,
IsInitiallyExpanded = false,
Selector = (c) => c.CategoryId
};

相关内容

最新更新