当前上下文中不存在名称 'context'

The name 'context' does not exist in the current context

这是我的代码:

<TelerikGrid Data="@forecasts"
                 Sortable="true"
                 FilterMode="GridFilterMode.FilterMenu"
                 Resizable="true">
        <GridColumns>
            <GridColumn Title="Date">
                <template>
                    @{
                        var forecast = context as WeatherForecast;

                    }
                </template>
            </GridColumn>
        </GridColumns>
    </TelerikGrid>

我做错了什么

这是 HTML 标签中大小写很重要的罕见情况之一。而不是:

<template>
    @{
        var forecast = context as WeatherForecast;
    }
</template>

你需要:

<Template>
    @{
        var forecast = context as WeatherForecast;
    }
</Template>