private static void UpdatePanel(Panel panel, Thickness spacing) { foreach (var child in panel.Children.OfType <FrameworkElement>()) { child.Margin = GetOverwrite(child) ?? spacing.Add(GetAdd(child)); } }