I have a wpf application in which I am using a wpf grid and adding/removing controls dynamically to it. Adding controls is fine but upon removing they disappear from the grid but left the vacant place in them, which I want to be occupied by filled by rest of the elements, just like they did in wrap panel.
Previously I was using the wrap panel and it works fine, but I need to add splitter control among my groupboxes thus I replaced the wrappanel with grid.
Here are the screenshots of the window
I remove the middle groupbox and it displays like this
I want the third groupbox to occupy the place of second groupbox. For the record, I have used grid resize event and this is the code it is having
foreach (var control in this.DynamicGrid.Children)
{
if (control.GetType() == typeof(GroupBox))
{
GroupBox groupBox = control as GroupBox;
groupBox.Height = this.DynamicGrid.ActualHeight;
this.WrapPanel1.Width = this.DynamicGrid.ActualWidth;
}
}
Wrappanel has dynamic grid in which we are adding/removing elements.