If you have grid called fileGrid you can remove the row using the following:
private void RemoveFileGridRow(int rowIndex)
{
for (int controlIndex = 0; controlIndex < fileGrid.Children.Count; controlIndex++)
{
UIElement control = fileGrid.Children[controlIndex];
int currentRowIndex = (int)control.GetValue(Grid.RowProperty);
if (currentRowIndex == rowIndex)
{
fileGrid.Children.RemoveAt(controlIndex--);
}
else if (currentRowIndex > rowIndex)
{
control.SetValue(Grid.RowProperty, currentRowIndex - 1);
}
}
fileGrid.RowDefinitions.RemoveAt(rowIndex);
}
This will remove the row and reorder the rows after the deleted row.
Alternatively, if you want to hide it, you can set the height of the row to 0.