private static int GetIndex(this GridSplitter gridSplitter) { var index = -1; switch (gridSplitter.GetResizeDirection()) { case GridResizeDirection.Columns: index = (int)gridSplitter.GetValue(Grid.ColumnProperty); break; case GridResizeDirection.Rows: index = (int)gridSplitter.GetValue(Grid.RowProperty); break; } return(index); }
private static IEnumerable <DefinitionBase> GetDefinitions(this Grid grid, GridSplitter gridSplitter) { var definitions = Enumerable.Empty <DefinitionBase>(); switch (gridSplitter.GetResizeDirection()) { case GridResizeDirection.Columns: definitions = grid.ColumnDefinitions; break; case GridResizeDirection.Rows: definitions = grid.RowDefinitions; break; } return(definitions); }
private static GridResizeBehavior GetResizeBehavior(this GridSplitter gridSplitter) { // The following logic is based on documentation at: https://msdn.microsoft.com/en-us/library/system.windows.controls.gridresizebehavior(v=vs.110).aspx var resizeBehavior = gridSplitter.ResizeBehavior; if (resizeBehavior == GridResizeBehavior.BasedOnAlignment) { if (gridSplitter.GetResizeDirection() == GridResizeDirection.Rows) { switch (gridSplitter.VerticalAlignment) { case VerticalAlignment.Top: resizeBehavior = GridResizeBehavior.PreviousAndCurrent; break; case VerticalAlignment.Bottom: resizeBehavior = GridResizeBehavior.CurrentAndNext; break; case VerticalAlignment.Center: case VerticalAlignment.Stretch: resizeBehavior = GridResizeBehavior.PreviousAndNext; break; } } else { switch (gridSplitter.HorizontalAlignment) { case HorizontalAlignment.Left: resizeBehavior = GridResizeBehavior.PreviousAndCurrent; break; case HorizontalAlignment.Right: resizeBehavior = GridResizeBehavior.CurrentAndNext; break; case HorizontalAlignment.Center: case HorizontalAlignment.Stretch: resizeBehavior = GridResizeBehavior.PreviousAndNext; break; } } } return(resizeBehavior); }