Blazor with MatBlazor using MatTableRow in AuthorizeView causes same parameter name error

2.2k views Asked by At

Error:

The child content element 'MatTableRow' of component 'MatTable' uses the same parameter name ('context') as enclosing child content element 'Authorized' of component 'AuthorizeView'.

Code:

<AuthorizeView>
    <Authorized>
        <h3>Products</h3>
        <MatTable Items="@sortedData" class="mat-elevation-z5" ShowPaging="false" UseSortHeaderRow="true" Striped="true"
                  FilterByColumnName="Label" DebounceMilliseconds="150" AllowSelection="true" SelectionChanged="SelectionChangedEvent">
            <MatTableHeader>
                <MatSortHeaderRow SortChanged="@SortData">
                    <MatSortHeader SortId="Label"><span style="width:600px">Label</span></MatSortHeader>
                    <MatSortHeader SortId="UseCases">Use cases</MatSortHeader>
                </MatSortHeaderRow>
            </MatTableHeader>
            <MatTableRow>
                <td>@context.Label</td>
                <td>@context.UseCases</td>
            </MatTableRow>
        </MatTable>
    </Authorized>
</AuthorizeView>
1

There are 1 answers

0
Ogglas On BEST ANSWER

Solve it by specifying context via parameter like this:

<MatTableRow Context="tableRowContext">
    <td>@tableRowContext.Label</td>
    <td>@tableRowContext.UseCases</td>
</MatTableRow>