public static LayoutConfiguration Save(Control control, string prefix = "LAYOUT_") { var layoutConfiguration = new LayoutConfiguration() { Name = "Default", GridLayouts = new List <GridLayout>(), TabLayouts = new List <TabLayout>() }; var logicalDescendants = control.GetLogicalDescendants(); foreach (var logicalDescendant in logicalDescendants) { if (logicalDescendant is Control logicalDescendantControl) { switch (logicalDescendantControl) { case Grid grid: { var gridLayout = CreateGridLayout(grid, prefix); if (gridLayout != null) { layoutConfiguration.GridLayouts.Add(gridLayout); } } break; case TabControl tabControl: { var tabLayout = CreateTabLayout(tabControl, prefix); if (tabLayout != null) { layoutConfiguration.TabLayouts.Add(tabLayout); } } break; } } } return(layoutConfiguration); }