How to create add and delete columns in WPF Grid Dynamically?

The Add method of Grid.ColumnDefinitions adds a new column to Grid.

DynamicGrid.ColumnDefinitions.Add(new ColumnDefinition());

 

The Grid.ColumnDefinitions.Insert method adds a column at a given position. The following code adds a new column at position 3 in a Grid.

DynamicGrid.ColumnDefinitions.Insert(3, new ColumnDefinition());

The RemoveAt method of Grid.ColumnDefinitions deletes a column at the given position.

DynamicGrid.ColumnDefinitions.RemoveAt(3);

 

The Clear method of Grid.ColumnDefinitions deletes all columns in a Grid.

DynamicGrid.ColumnDefinitions.Clear();