private void OnScrollCommand(object sender, ExecutedRoutedEventArgs e) { double scrollingViewport = this.ViewportWidth; FixedCellPanel cellPanel = this.LocateFixedCellPanel(this); if (cellPanel != null) { scrollingViewport -= cellPanel.GetFixedWidth(); } if (e.Command == ScrollBar.PageLeftCommand) { double newOffset = Math.Max(this.HorizontalOffset - scrollingViewport, 0d); this.ScrollToHorizontalOffset(newOffset); e.Handled = true; } else if (e.Command == ScrollBar.PageRightCommand) { double newOffset = Math.Min(this.HorizontalOffset + scrollingViewport, this.ScrollableWidth); this.ScrollToHorizontalOffset(newOffset); e.Handled = true; } else { System.Diagnostics.Debug.Assert(false); } }
public FixedCellSubPanel(FixedCellPanel parentPanel) { if (parentPanel == null) { throw new ArgumentNullException("parentPanel"); } m_parentPanel = parentPanel; }
private bool IsCellsOffsetNeedReset(DataGridContext dataGridContext) { var columnVirtualizationManager = dataGridContext.ColumnVirtualizationManager as TableViewColumnVirtualizationManagerBase; if (columnVirtualizationManager == null) { return(false); } Cell targetCell = dataGridContext.CurrentCell; // if the targetCell is null, it means we are on a header or.. (a non focusable item) // we want to scroll as the "no navigation" behavior if (targetCell == null) { return(true); } FixedCellPanel fixedCellPanel = targetCell.ParentRow.CellsHostPanel as FixedCellPanel; DataGridItemsHost itemsHost = dataGridContext.DataGridControl.ItemsHost as DataGridItemsHost; double viewportWidth = this.ViewportWidth; double fixedColumnWidth = columnVirtualizationManager.FixedColumnsWidth; double cellsWidth = targetCell.ParentColumn.Width; Point cellToScrollingCellsDecorator = targetCell.TranslatePoint(new Point(), fixedCellPanel.ScrollingCellsDecorator); bool leftEdgeOutOfViewPort; // verify if the cell's left edge is visible in the viewPort leftEdgeOutOfViewPort = (cellToScrollingCellsDecorator.X < 0) ? true : false; // Verify if the Cell's right edge is visible in the ViewPort Point cellToItemsHost = targetCell.TranslatePoint(new Point(cellsWidth, 0), itemsHost); // If the right edge is out of Viewport, ensure not to call the resetHorizontalOffset bool rightEdgeOutOfViewPort = ((cellToItemsHost.X - viewportWidth) > 0) ? true : false; bool resetHorizontalOffset = false; // if the cell is inside the viewPort or if one of the edges of the cell are outside the portView but the // the viewPort is not wide enough to contain the cell if (((!rightEdgeOutOfViewPort) && (!leftEdgeOutOfViewPort)) || (((rightEdgeOutOfViewPort) || (leftEdgeOutOfViewPort)) && ((cellsWidth - Math.Abs(cellToScrollingCellsDecorator.X)) >= (viewportWidth - fixedColumnWidth)))) { resetHorizontalOffset = true; } return(resetHorizontalOffset); }
private static void OnColumnReordering(object sender, ColumnReorderingEventArgs e) { FixedCellPanel panel = sender as FixedCellPanel; if (panel == null) { return; } DataGridContext dataGridContext = DataGridControl.GetDataGridContext(panel); if (dataGridContext == null) { return; } TableViewColumnVirtualizationManager columnVirtualizationManager = dataGridContext.ColumnVirtualizationManager as TableViewColumnVirtualizationManager; if (columnVirtualizationManager == null) { return; } int currentFixedColumnCount = columnVirtualizationManager.FixedColumnCount; // We must be sure the VisiblePosition is converted to visible index since some Columns can be Visible = false int oldVisiblePosition = FixedCellPanel.CalculateVisibleIndex(e.OldVisiblePosition, dataGridContext); int newVisiblePosition = FixedCellPanel.CalculateVisibleIndex(e.NewVisiblePosition, dataGridContext); if ((oldVisiblePosition < columnVirtualizationManager.FixedColumnCount) && (newVisiblePosition >= columnVirtualizationManager.FixedColumnCount)) { // A column was moved from the fixedPanel to the scrollingPanel // Do not increment version, it will be done by the FixedColumnCount changed TableView.SetFixedColumnCount(columnVirtualizationManager.DataGridContext, columnVirtualizationManager.FixedColumnCount - 1); } else if ((oldVisiblePosition >= columnVirtualizationManager.FixedColumnCount) && (newVisiblePosition < columnVirtualizationManager.FixedColumnCount)) { // A column was moved from the scrollingPanel to the fixedPanel // Do not increment version, it will be done by the FixedColumnCount changed TableView.SetFixedColumnCount(columnVirtualizationManager.DataGridContext, columnVirtualizationManager.FixedColumnCount + 1); } else { columnVirtualizationManager.IncrementVersion(new UpdateMeasureRequiredEventArgs(UpdateMeasureTriggeredAction.ColumnReordering)); } // This must be done to stop progation of the event even // if only 1 ColumnManagerCell will raise it. e.Handled = true; }
// The visualParent is passed to the base constructor because it is mandatory, but // the element's visual parent will always be either the fixed or the scrolling sub // panel. This is one of the reason why we don't use the base implementation of this // class functions. public VirtualizingUICellCollection(Panel fixedPanel, Panel scrollingPanel, FixedCellPanel parentFixedCellPanel) : base(parentFixedCellPanel, parentFixedCellPanel) { if (fixedPanel == null) { throw new ArgumentNullException("fixedPanel"); } if (scrollingPanel == null) { throw new ArgumentNullException("scrollingPanel"); } if (parentFixedCellPanel == null) { throw new ArgumentNullException("parentFixedCellPanel"); } m_fixedPanel = fixedPanel; m_scrollingPanel = scrollingPanel; m_parentFixedCellPanel = parentFixedCellPanel; }
public VirtualizingFixedCellSubPanel(FixedCellPanel parentPanel) : base(parentPanel) { }