public static void ReorderWidgets(Box box) { var items = new ChildPacking[box.Children.Length]; for (int i = 0; i < items.Length; i++) { bool expand, fill; uint padding; PackType packType; box.QueryChildPacking(box.Children[i], out expand, out fill, out padding, out packType); items[i] = new ChildPacking { Expand = expand, Fill = fill, Padding = padding, PackType = packType, Widget = box.Children[i] }; } foreach (var item in items) { box.Remove(item.Widget); } foreach (var item in items) { box.PackEnd(item.Widget); box.SetChildPacking(item.Widget, item.Expand, item.Fill, item.Padding, item.PackType); } }