private static LayoutUpdateEventHandler CreateLayoutUpdateHandler(Grid grid) { var prevCount = 0; var prevColumn = grid.ColumnDefinitions.Count; var prevRow = grid.RowDefinitions.Count; var prevOrientation = GetAutoFillOrientation(grid); var layoutUpdateCallback = new LayoutUpdateEventHandler((sender, args) => { var count = grid.Children.Count; var column = grid.ColumnDefinitions.Count; var row = grid.RowDefinitions.Count; var orientation = GetAutoFillOrientation(grid); if (count != prevCount || column != prevColumn || row != prevRow || orientation != prevOrientation) { AutoFill(grid); prevCount = count; prevColumn = column; prevRow = row; prevOrientation = orientation; } }); return(layoutUpdateCallback); }
private static void SetLayoutUpdatedCallback(DependencyObject obj, LayoutUpdateEventHandler value) { obj.SetValue(LayoutUpdatedCallbackProperty, value); }