wpf 删除行并删除行中的控件
int index = Grid.GetRow(label);//删除按钮所在的行号 List<FrameworkElement> list = new List<FrameworkElement>();//存取同一行中的控件 foreach (FrameworkElement item in grid.Children) { int itemIndex = Grid.GetRow(item);//当前控件所在的行号 if (itemIndex == index) { list.Add(item);//同一行中的控件添加到集合 } } if (list != null) { foreach (FrameworkElement item in list) { grid.Children.Remove(item);//移除 } }