'How to Add and Remove specific columns from Grid?

I'm trying to remove a specific column/row when the window ActualWidth and ActualHeight is over 700. I couldn't really find a way to remove a specific column/row besides

myGrid.ColumnDefinitions.RemoveAt(1);

which removes one column everytime the widow size changes.

Current Grid:

<Grid x:Name="myGrid">
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition MaxHeight="80" MinHeight="80"/>
        <RowDefinition MaxHeight="80" MinHeight="80"/>
        <RowDefinition MaxHeight="80" MinHeight="80"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions >
        <ColumnDefinition MaxWidth="170" MinWidth="170" x:Name="ColumnThatNeedsToBeRemovedAndReadded"/>
        <ColumnDefinition MinWidth="110" Width="*"/>
        <ColumnDefinition MinWidth="350" MaxWidth="700"/>
        <ColumnDefinition MinWidth="170" Width="*"/>
    </Grid.ColumnDefinitions>
</Grid>

Code which Adds/Removes:

 if (ActualHeight > 700 && ActualWidth > 700)
 {
    myGrid.ColumnDefinitions.RemoveAt(1);
 }
 else if(ActualHeight < 700 && ActualWidth > 700)
 {
    myGrid.ColumnDefinitions.Add(new ColumnDefinition());
 }


Solution 1:[1]

You can do something like this to remove a specific column:

   for (var index = 0; index < myGrid.ColumnDefinitions.Count; index++)
    {
        var currentCol = myGrid.ColumnDefinitions[index];
        if (currentCol.ActualWidth > 700)
        {
            myGrid.Children.RemoveAt(index);
        }
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ohad Cohen