Access Context in the component itself

So let say we have:

<RadzenDataGrid  ...>
        <RadzenDataGridColumn Context="item" TItem="User" Property="FirstName" ...>

And I want to avoid the error-prone magic string in "Property"

<RadzenDataGrid  ...>
        <RadzenDataGridColumn Context="item" TItem="User" Property="@(nameof(item.FirstName))" ...>

Which obviously doesn't work because "item" is not accessible in the markup itself.

Is there any workaround?

Context is available only in templates.

You can use nameof with the class itself. You don't need the context.

<RadzenDataGridColumn TItem="User" Property=@nameof(User.FirstName) />
1 Like

Excellent! Works like a charm, Thanks!