DataGrid - Conditional columns keep adding up

I have a DataGrid where I want to show the Edit column (as an example) only when the page is in "edit" mode. For this, I have a variable that I watch.

A very simplified version:

         <RadzenGrid AllowFiltering="false" AllowPaging="true" AllowSorting="true" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
                Data="@projectBuyouts" TItem="Buyout" @ref="projectBuyoutGrid">
        <Columns>
            <RadzenGridColumn TItem="Buyout" Property="Name" Title="Name" Width="130px">
            </RadzenGridColumn>
            <RadzenGridColumn TItem="Buyout" Title="Sum" Width="50px" TextAlign="TextAlign.Right">
            </RadzenGridColumn>
            @if (AllowEdit)
            {
            <RadzenGridColumn TItem="Buyout" Title="Edit" Bubble="false" Filterable="false" Sortable="false" TextAlign="TextAlign.Right" Width="64px">
            </RadzenGridColumn>
            }
        </Columns>
    </RadzenGrid>

As you can see, the Edit column should disappear when AllowEdit is false. And it does. However, every time I toggle the value, another Edit column gets added.

image

What am I overlooking here please?

Have you tried to debug it using Visual Studio debugger?

It does not add a new column to the columncollection of the grid, it just inserts it again into the document without removing the old one when the "AllowEdit" switches to false.

Ok it works if I manually remove it like this on change:

var column = projectBuyoutGrid.ColumnsCollection.SingleOrDefault(pp=>pp.Title=="Edit");
if (column != null) {
     projectBuyoutGrid.ColumnsCollection.Remove(column);
}