private static void SetElementLayout(FrameworkElement element, LayoutArgumentType type) { element.SetGridLayoutValue(ColumnProperty, type); element.SetGridLayoutValue(RowProperty, type); element.SetGridLayoutValue(ColumnSpanProperty, type); element.SetGridLayoutValue(RowSpanProperty, type); }
private static void UpdateLayout(Grid grid, LayoutArgumentType type, Action <FrameworkElement, LayoutArgumentType> action) { foreach (var child in grid.Children) { if (child is FrameworkElement element && GetIsChildEnabled(element)) { action?.Invoke(element, type); } } }
internal static int?GetSizeFromArguments(this string arguments, LayoutArgumentType type) { var map = arguments.ToLayoutTypeMap(); int?result = null; if (map.ContainsKey(type)) { result = map[type]; } return(result); }
private static bool LayoutStateChanged(double gridWidth, double?oldWidth, LayoutLimitCollection limits, out LayoutArgumentType newLayoutState) { var newState = limits.GetLayoutType(gridWidth); var result = true; newLayoutState = newState ?? throw new ArgumentOutOfRangeException(nameof(gridWidth)); var oldState = limits.GetLayoutType(oldWidth); if (oldState.HasValue) { result = newState != oldState; } return(result); }
internal static void AddOrUpdate(this IDictionary <LayoutArgumentType, int?> dictionary, LayoutArgumentType type, int?value) { if (dictionary.ContainsKey(type)) { dictionary[type] = value; } else { dictionary.Add(type, value); } }
internal static void SetGridLayoutValue(this FrameworkElement element, DependencyProperty property, LayoutArgumentType type) { var arguments = element.GetValue(property) as string; var value = arguments.GetSizeFromArguments(type); if (value.HasValue) { var targetProperty = GridLayout.ToGridPropertiesMap[property]; element.SetValue(targetProperty, value); } }