public void OnColumnsChange(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: if (e.NewItems == null) { return; } Logger.Debug("Adding new columns"); Application.Current.Dispatcher.BeginInvoke((Action)(() => { foreach (GridColumn col in e.NewItems) { AddColumn(col); } })); break; case NotifyCollectionChangedAction.Remove: if (e.OldItems == null) { return; } Logger.Debug("Removing columns"); Application.Current.Dispatcher.BeginInvoke((Action)(() => { foreach (GridColumn col in e.OldItems) { var colName = col.ColumnType == GridColumn.ColumnTypeEnum.Category ? col.Category.CategoryName : col.Header; ColumnManager.RemoveColumn(colName); } })); break; } }