internal void PrintDisplay() { foreach (UIElement element in this.GetScrollingElements()) { DataGridRow row = element as DataGridRow; if (row != null) { Debug.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Slot: {0} Row: {1} ", row.Slot, row.Index)); } else { DataGridRowGroupHeader groupHeader = element as DataGridRowGroupHeader; if (groupHeader != null) { #if FEATURE_ICOLLECTIONVIEW_GROUP Debug.WriteLine(string.Format( System.Globalization.CultureInfo.InvariantCulture, "Slot: {0} GroupHeader: {1}", groupHeader.RowGroupInfo.Slot, groupHeader.RowGroupInfo.CollectionViewGroup.Name)); #else Debug.WriteLine(string.Format( System.Globalization.CultureInfo.InvariantCulture, "Slot: {0} GroupHeader: {1}", groupHeader.RowGroupInfo.Slot, groupHeader.RowGroupInfo.ToString())); #endif } } } }
internal void RaiseAutomationFocusChangedEvent(int slot, int column) { if (slot >= 0 && slot < this.OwningDataGrid.SlotCount && column >= 0 && column < this.OwningDataGrid.ColumnsItemsInternal.Count && this.OwningDataGrid.IsSlotVisible(slot)) { if (this.OwningDataGrid.RowGroupHeadersTable.Contains(slot)) { DataGridRowGroupHeader header = this.OwningDataGrid.DisplayData.GetDisplayedElement(slot) as DataGridRowGroupHeader; if (header != null) { AutomationPeer headerPeer = CreatePeerForElement(header); if (headerPeer != null) { #if DEBUG_AUTOMATION Debug.WriteLine(headerPeer.ToString() + ".RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged)"); #endif headerPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged); } } } else { AutomationPeer cellPeer = GetCellPeer(slot, column); if (cellPeer != null) { #if DEBUG_AUTOMATION Debug.WriteLine(cellPeer.ToString() + ".RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged)"); #endif cellPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged); } } } }
internal void AddRecylableRowGroupHeader(DataGridRowGroupHeader groupHeader) { Debug.Assert(!_recyclableGroupHeaders.Contains(groupHeader), "Expected groupHeader parameter to be non-recyclable."); groupHeader.PropertyName = null; groupHeader.PropertyValue = null; groupHeader.IsRecycled = true; _recyclableGroupHeaders.Push(groupHeader); }
internal void UpdateRowGroupHeaderPeerEventsSource(DataGridRowGroupHeader header) { object group = header.RowGroupInfo.CollectionViewGroup; DataGridRowGroupHeaderAutomationPeer peer = DataGridRowGroupHeaderAutomationPeer.FromElement(header) as DataGridRowGroupHeaderAutomationPeer; if (peer != null && group != null && _groupItemPeers.ContainsKey(group)) { peer.EventsSource = _groupItemPeers[group]; } }
internal DataGridRowGroupHeader GetUsedGroupHeader() { if (_recyclableGroupHeaders.Count > 0) { return(_recyclableGroupHeaders.Pop()); } else if (_fullyRecycledGroupHeaders.Count > 0) { // For fully recycled rows, we need to set the Visibility back to Visible DataGridRowGroupHeader groupHeader = _fullyRecycledGroupHeaders.Pop(); groupHeader.Visibility = Visibility.Visible; return(groupHeader); } return(null); }
/// <summary> /// Arranges the content of the <see cref="DataGridRowsPresenter"/>. /// </summary> /// <returns> /// The actual size used by the <see cref="DataGridRowsPresenter"/>. /// </returns> /// <param name="finalSize"> /// The final area within the parent that this element should use to arrange itself and its children. /// </param> protected override Size ArrangeOverride(Size finalSize) { if (finalSize.Height == 0 || this.OwningGrid == null) { return(base.ArrangeOverride(finalSize)); } this.OwningGrid.OnFillerColumnWidthNeeded(finalSize.Width); double rowDesiredWidth = this.OwningGrid.ColumnsInternal.VisibleEdgedColumnsWidth + this.OwningGrid.ColumnsInternal.FillerColumn.FillerWidth; double topEdge = -this.OwningGrid.NegVerticalOffset; foreach (UIElement element in this.OwningGrid.DisplayData.GetScrollingElements()) { DataGridRow row = element as DataGridRow; if (row != null) { DiagnosticsDebug.Assert(row.Index != -1, "Expected Index other than -1."); // A displayed row should always have its index // Visibility for all filler cells needs to be set in one place. Setting it individually in // each CellsPresenter causes an NxN layout cycle (see DevDiv Bugs 211557) row.EnsureFillerVisibility(); row.Arrange(new Rect(-this.OwningGrid.HorizontalOffset, topEdge, rowDesiredWidth, element.DesiredSize.Height)); } else { DataGridRowGroupHeader groupHeader = element as DataGridRowGroupHeader; if (groupHeader != null) { double leftEdge = this.OwningGrid.AreRowGroupHeadersFrozen ? 0 : -this.OwningGrid.HorizontalOffset; groupHeader.Arrange(new Rect(leftEdge, topEdge, rowDesiredWidth - leftEdge, element.DesiredSize.Height)); } } topEdge += element.DesiredSize.Height; } double finalHeight = Math.Max(topEdge + this.OwningGrid.NegVerticalOffset, finalSize.Height); // Clip the RowsPresenter so rows cannot overlap other elements in certain styling scenarios RectangleGeometry rg = new RectangleGeometry(); rg.Rect = new Rect(0, 0, finalSize.Width, finalHeight); this.Clip = rg; return(new Size(finalSize.Width, finalHeight)); }
internal void PrintChildren() { foreach (UIElement element in this.Children) { DataGridRow row = element as DataGridRow; if (row != null) { Debug.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Slot: {0} Row: {1} Visibility: {2} ", row.Slot, row.Index, row.Visibility)); } else { DataGridRowGroupHeader groupHeader = element as DataGridRowGroupHeader; if (groupHeader != null) { Debug.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Slot: {0} GroupHeader: {1} Visibility: {2}", groupHeader.RowGroupInfo.Slot, groupHeader.RowGroupInfo.CollectionViewGroup.Name, groupHeader.Visibility)); } } } }
internal void ClearElements(bool recycle) { ResetSlotIndexes(); if (recycle) { foreach (UIElement element in _scrollingElements) { DataGridRow row = element as DataGridRow; if (row != null) { if (row.IsRecyclable) { AddRecylableRow(row); } else { row.Clip = new RectangleGeometry(); } } else { DataGridRowGroupHeader groupHeader = element as DataGridRowGroupHeader; if (groupHeader != null) { AddRecylableRowGroupHeader(groupHeader); } } } } else { _recyclableRows.Clear(); _fullyRecycledRows.Clear(); _recyclableGroupHeaders.Clear(); _fullyRecycledGroupHeaders.Clear(); } _scrollingElements.Clear(); }
internal void FullyRecycleElements() { // Fully recycle Recycleable rows and transfer them to Recycled rows while (_recyclableRows.Count > 0) { DataGridRow row = _recyclableRows.Pop(); Debug.Assert(row != null, "Expected non-null row."); row.Visibility = Visibility.Collapsed; Debug.Assert(!_fullyRecycledRows.Contains(row), "Expected row not in _fullyRecycledRows."); _fullyRecycledRows.Push(row); } // Fully recycle recyclable GroupHeaders and transfer them to Recycled GroupHeaders while (_recyclableGroupHeaders.Count > 0) { DataGridRowGroupHeader groupHeader = _recyclableGroupHeaders.Pop(); Debug.Assert(groupHeader != null, "Expected non-null groupHeader."); groupHeader.Visibility = Visibility.Collapsed; Debug.Assert(!_fullyRecycledGroupHeaders.Contains(groupHeader), "Expected groupHeader not in _fullyRecycledGroupHeaders."); _fullyRecycledGroupHeaders.Push(groupHeader); } }
internal void PrintChildren() { foreach (UIElement element in this.Children) { DataGridRow row = element as DataGridRow; if (row != null) { System.Diagnostics.Debug.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Slot: {0} Row: {1} Visibility: {2} ", row.Slot, row.Index, row.Visibility)); } else { DataGridRowGroupHeader groupHeader = element as DataGridRowGroupHeader; if (groupHeader != null) { #if FEATURE_ICOLLECTIONVIEW_GROUP System.Diagnostics.Debug.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Slot: {0} GroupHeader: {1} Visibility: {2}", groupHeader.RowGroupInfo.Slot, groupHeader.RowGroupInfo.CollectionViewGroup.Name, groupHeader.Visibility)); #else System.Diagnostics.Debug.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Slot: {0} Visibility: {1}", groupHeader.RowGroupInfo.Slot, groupHeader.Visibility)); #endif } } } }
/// <summary> /// Measures the children of a <see cref="T:System.Windows.Controls.Primitives.DataGridRowsPresenter" /> to /// prepare for arranging them during the <see cref="M:System.Windows.FrameworkElement.ArrangeOverride(System.Windows.Size)" /> pass. /// </summary> /// <param name="availableSize"> /// The available size that this element can give to child elements. Indicates an upper limit that child elements should not exceed. /// </param> /// <returns> /// The size that the <see cref="T:System.Windows.Controls.Primitives.DataGridRowsPresenter" /> determines it needs during layout, based on its calculations of child object allocated sizes. /// </returns> protected override Size MeasureOverride(Size availableSize) { if (availableSize.Height == 0 || this.OwningGrid == null) { return(base.MeasureOverride(availableSize)); } // If the Width of our RowsPresenter changed then we need to invalidate our rows bool invalidateRows = (!this.OwningGrid.RowsPresenterAvailableSize.HasValue || availableSize.Width != this.OwningGrid.RowsPresenterAvailableSize.Value.Width) && !double.IsInfinity(availableSize.Width); // The DataGrid uses the RowsPresenter available size in order to autogrow // and calculate the scrollbars this.OwningGrid.RowsPresenterAvailableSize = availableSize; this.OwningGrid.OnRowsMeasure(); double totalHeight = -this.OwningGrid.NegVerticalOffset; double totalCellsWidth = this.OwningGrid.ColumnsInternal.VisibleEdgedColumnsWidth; double headerWidth = 0; foreach (UIElement element in this.OwningGrid.DisplayData.GetScrollingElements()) { DataGridRow row = element as DataGridRow; if (row != null) { if (invalidateRows) { row.InvalidateMeasure(); } } element.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); if (row != null && row.HeaderCell != null) { headerWidth = Math.Max(headerWidth, row.HeaderCell.DesiredSize.Width); } else { DataGridRowGroupHeader groupHeader = element as DataGridRowGroupHeader; if (groupHeader != null && groupHeader.HeaderCell != null) { headerWidth = Math.Max(headerWidth, groupHeader.HeaderCell.DesiredSize.Width); } } totalHeight += element.DesiredSize.Height; } this.OwningGrid.RowHeadersDesiredWidth = headerWidth; // Could be positive infinity depending on the DataGrid's bounds this.OwningGrid.AvailableSlotElementRoom = availableSize.Height - totalHeight; // totalHeight = Math.Max(0, totalHeight); return(new Size(totalCellsWidth + headerWidth, totalHeight)); }
/// <summary> /// Constructs a DataGridRowGroupHeaderEventArgs instance /// </summary> /// <param name="rowGroupHeader"></param> public DataGridRowGroupHeaderEventArgs(DataGridRowGroupHeader rowGroupHeader) { this.RowGroupHeader = rowGroupHeader; }
public static void SetContentTemplate(DataGridRowGroupHeader ui, DataTemplate value) { ui.SetValue(ContentTemplateProperty, value); }
public static DataTemplate GetContentTemplate(DataGridRowGroupHeader ui) { return((DataTemplate)ui.GetValue(ContentTemplateProperty)); }
/// <summary> /// Initializes a new instance of the <see cref="DataGridRowGroupHeaderAutomationPeer"/> class. /// </summary> /// <param name="owner">DataGridRowGroupHeader</param> public DataGridRowGroupHeaderAutomationPeer(DataGridRowGroupHeader owner) : base(owner) { }
/// <summary> /// Constructs a DataGridRowGroupHeaderEventArgs instance /// </summary> /// <param name="rowGroupHeader"></param> public DataGridRowGroupHeaderEventArgs(DataGridRowGroupHeader rowGroupHeader) { this.RowGroupHeader = rowGroupHeader; }