I'm trying to dynamically load columns when DataGrid
is loaded, and add the event handler with some parameters in initialization.
dataGrid.Loaded += (sender, args) => AddColumns(dataGrid, GetAttachedColumns(dataGrid));
But have no idea to how to remove this handler after DataGrid is loaded. The following code doesn't work.
dataGrid.Loaded -= (sender, args) => AddColumns(dataGrid, GetAttachedColumns(dataGrid));
Please help out. Thanks.