/// <summary> /// GridViewRowPresenter computes the position of its children inside each child's Margin and calls Arrange /// on each child. /// </summary> /// <param name="arrangeSize">Size the GridViewRowPresenter will assume.</param> protected override Size ArrangeOverride(Size arrangeSize) { GridViewColumnCollection columns = Columns; if (columns == null) { return(arrangeSize); } UIElementCollection children = InternalChildren; double accumulatedWidth = 0.0; double remainingWidth = arrangeSize.Width; foreach (GridViewColumn column in columns) { UIElement child = children[column.ActualIndex]; if (child == null) { continue; } // has a given value or 'auto' double childArrangeWidth = Math.Min(remainingWidth, ((column.State == ColumnMeasureState.SpecificWidth) ? column.Width : column.DesiredWidth)); child.Arrange(new Rect(accumulatedWidth, 0, childArrangeWidth, arrangeSize.Height)); remainingWidth -= childArrangeWidth; accumulatedWidth += childArrangeWidth; } return(arrangeSize); }
//------------------------------------------------------------------- // // Internal Methods / Properties // //------------------------------------------------------------------- #region Internal Methods / Properties /// <summary> /// Called when the Template's tree has been generated /// </summary> internal override void OnPreApplyTemplate() { // +-- GridViewRowPresenter ------------------------------------+ // | | // | +- CtPstr1 ---+ +- CtPstr2 ---+ +- CtPstr3 ---+ | // | | | | | | | ... | // | +-------------+ +-------------+ +-------------+ | // +------------------------------------------------------------+ base.OnPreApplyTemplate(); if (NeedUpdateVisualTree) { InternalChildren.Clear(); // build the whole collection from draft. GridViewColumnCollection columns = Columns; if (columns != null) { foreach (GridViewColumn column in columns.ColumnCollection) { InternalChildren.AddInternal(CreateCell(column)); } } NeedUpdateVisualTree = false; } // invalidate viewPort cache _viewPortValid = false; }
/// <summary>Positions the content of a row according to the size of the corresponding <see cref="T:System.Windows.Controls.GridViewColumn" /> objects.</summary> /// <param name="arrangeSize">The area to use to display the <see cref="P:System.Windows.Controls.GridViewRowPresenter.Content" />.</param> /// <returns>The actual <see cref="T:System.Windows.Size" /> that is used to display the <see cref="P:System.Windows.Controls.GridViewRowPresenter.Content" />.</returns> // Token: 0x06004DA5 RID: 19877 RVA: 0x0015E078 File Offset: 0x0015C278 protected override Size ArrangeOverride(Size arrangeSize) { GridViewColumnCollection columns = base.Columns; if (columns == null) { return(arrangeSize); } UIElementCollection internalChildren = base.InternalChildren; double num = 0.0; double num2 = arrangeSize.Width; foreach (GridViewColumn gridViewColumn in columns) { UIElement uielement = internalChildren[gridViewColumn.ActualIndex]; if (uielement != null) { double num3 = Math.Min(num2, (gridViewColumn.State == ColumnMeasureState.SpecificWidth) ? gridViewColumn.Width : gridViewColumn.DesiredWidth); uielement.Arrange(new Rect(num, 0.0, num3, arrangeSize.Height)); num2 -= num3; num += num3; } } return(arrangeSize); }
// Token: 0x06004DAE RID: 19886 RVA: 0x0015E5B0 File Offset: 0x0015C7B0 private void OnLayoutUpdated(object sender, EventArgs e) { bool flag = false; GridViewColumnCollection columns = base.Columns; if (columns != null) { foreach (GridViewColumn gridViewColumn in columns) { if (gridViewColumn.State != ColumnMeasureState.SpecificWidth) { gridViewColumn.State = ColumnMeasureState.Data; if (base.DesiredWidthList == null || gridViewColumn.ActualIndex >= base.DesiredWidthList.Count) { flag = true; break; } if (!DoubleUtil.AreClose(gridViewColumn.DesiredWidth, base.DesiredWidthList[gridViewColumn.ActualIndex])) { base.DesiredWidthList[gridViewColumn.ActualIndex] = gridViewColumn.DesiredWidth; flag = true; } } } } if (flag) { base.InvalidateMeasure(); } base.LayoutUpdated -= this.OnLayoutUpdated; }
/// <summary> /// Writes the attached property GridViewColumnCollection to the given element. /// </summary> /// <param name="element">The element to which to write the GridViewColumnCollection attached property.</param> /// <param name="collection">The collection to set</param> public static void SetColumnCollection(DependencyObject element, GridViewColumnCollection collection) { if (element == null) { throw new ArgumentNullException("element"); } element.SetValue(ColumnCollectionProperty, collection); }
/// <summary>Determines the area that is required to display the row. </summary> /// <param name="constraint">The maximum area to use to display the <see cref="P:System.Windows.Controls.GridViewRowPresenter.Content" />. </param> /// <returns>The actual <see cref="T:System.Windows.Size" /> of the area that displays the <see cref="P:System.Windows.Controls.GridViewRowPresenter.Content" />.</returns> // Token: 0x06004DA4 RID: 19876 RVA: 0x0015DE9C File Offset: 0x0015C09C protected override Size MeasureOverride(Size constraint) { GridViewColumnCollection columns = base.Columns; if (columns == null) { return(default(Size)); } UIElementCollection internalChildren = base.InternalChildren; double num = 0.0; double num2 = 0.0; double height = constraint.Height; bool flag = false; foreach (GridViewColumn gridViewColumn in columns) { UIElement uielement = internalChildren[gridViewColumn.ActualIndex]; if (uielement != null) { double num3 = Math.Max(0.0, constraint.Width - num2); if (gridViewColumn.State == ColumnMeasureState.Init || gridViewColumn.State == ColumnMeasureState.Headered) { if (!flag) { base.EnsureDesiredWidthList(); base.LayoutUpdated += this.OnLayoutUpdated; flag = true; } uielement.Measure(new Size(num3, height)); if (this.IsOnCurrentPage) { gridViewColumn.EnsureWidth(uielement.DesiredSize.Width); } base.DesiredWidthList[gridViewColumn.ActualIndex] = gridViewColumn.DesiredWidth; num2 += gridViewColumn.DesiredWidth; } else if (gridViewColumn.State == ColumnMeasureState.Data) { num3 = Math.Min(num3, gridViewColumn.DesiredWidth); uielement.Measure(new Size(num3, height)); num2 += gridViewColumn.DesiredWidth; } else { num3 = Math.Min(num3, gridViewColumn.Width); uielement.Measure(new Size(num3, height)); num2 += gridViewColumn.Width; } num = Math.Max(num, uielement.DesiredSize.Height); } } this._isOnCurrentPageValid = false; num2 += 2.0; return(new Size(num2, num)); }
private void OnLayoutUpdated(object sender, EventArgs e) { bool desiredWidthChanged = false; // whether the shared minimum width has been changed since last layout GridViewColumnCollection columns = Columns; if (columns != null) { foreach (GridViewColumn column in columns) { if ((column.State != ColumnMeasureState.SpecificWidth)) { column.State = ColumnMeasureState.Data; if (DesiredWidthList == null || column.ActualIndex >= DesiredWidthList.Count) { // How can this happen? // Between the last measure was called and this update is called, there can be a // change done to the ColumnCollection and result in DesiredWidthList out of sync // with the columnn collection. What can we do is end this call asap and the next // measure will fix it. desiredWidthChanged = true; break; } if (!DoubleUtil.AreClose(column.DesiredWidth, DesiredWidthList[column.ActualIndex])) { // Update the record because collection operation latter on might // need to verified this list again, e.g. insert an 'auto' // column, so that we won't trigger unnecessary update due to // inconsistency of this column. DesiredWidthList[column.ActualIndex] = column.DesiredWidth; desiredWidthChanged = true; } } } } if (desiredWidthChanged) { InvalidateMeasure(); } LayoutUpdated -= new EventHandler(OnLayoutUpdated); }
// Token: 0x06004DA6 RID: 19878 RVA: 0x0015E144 File Offset: 0x0015C344 internal override void OnPreApplyTemplate() { base.OnPreApplyTemplate(); if (base.NeedUpdateVisualTree) { base.InternalChildren.Clear(); GridViewColumnCollection columns = base.Columns; if (columns != null) { foreach (GridViewColumn column in columns.ColumnCollection) { base.InternalChildren.AddInternal(this.CreateCell(column)); } } base.NeedUpdateVisualTree = false; } this._viewPortValid = false; }
public static bool ShouldSerializeColumnCollection(DependencyObject obj) { ListViewItem listViewItem = obj as ListViewItem; if (listViewItem != null) { ListView listView = listViewItem.ParentSelector as ListView; if (listView != null) { GridView gridView = listView.View as GridView; if (gridView != null) { GridViewColumnCollection gridViewColumnCollection = listViewItem.ReadLocalValue(GridView.ColumnCollectionProperty) as GridViewColumnCollection; return(gridViewColumnCollection != gridView.Columns); } } } return(true); }
public static bool ShouldSerializeColumnCollection(DependencyObject obj) { ListViewItem listViewItem = obj as ListViewItem; if (listViewItem != null) { ListView listView = listViewItem.ParentSelector as ListView; if (listView != null) { GridView gridView = listView.View as GridView; if (gridView != null) { // if GridViewColumnCollection attached on ListViewItem is Details.Columns, it should't be serialized. GridViewColumnCollection localValue = listViewItem.ReadLocalValue(ColumnCollectionProperty) as GridViewColumnCollection; return(localValue != gridView.Columns); } } } return(true); }
//------------------------------------------------------------------- // // Protected Methods // //------------------------------------------------------------------- #region Protected Methods /// <summary> /// Override of <seealso cref="FrameworkElement.MeasureOverride" />. /// </summary> /// <param name="constraint">Constraint size is an "upper limit" that the return value should not exceed.</param> /// <returns>The GridViewRowPresenter's desired size.</returns> protected override Size MeasureOverride(Size constraint) { GridViewColumnCollection columns = Columns; if (columns == null) { return(new Size()); } UIElementCollection children = InternalChildren; double maxHeight = 0.0; // Max height of children. double accumulatedWidth = 0.0; // Total width consumed by children. double constraintHeight = constraint.Height; bool desiredWidthListEnsured = false; foreach (GridViewColumn column in columns) { UIElement child = children[column.ActualIndex]; if (child == null) { continue; } double childConstraintWidth = Math.Max(0.0, constraint.Width - accumulatedWidth); if (column.State == ColumnMeasureState.Init || column.State == ColumnMeasureState.Headered) { if (!desiredWidthListEnsured) { EnsureDesiredWidthList(); LayoutUpdated += new EventHandler(OnLayoutUpdated); desiredWidthListEnsured = true; } // Measure child. child.Measure(new Size(childConstraintWidth, constraintHeight)); // As long as this is the first round of measure that has data participate // the width should be ensured // only element on current page paticipates in calculating the shared width if (IsOnCurrentPage) { column.EnsureWidth(child.DesiredSize.Width); } DesiredWidthList[column.ActualIndex] = column.DesiredWidth; accumulatedWidth += column.DesiredWidth; } else if (column.State == ColumnMeasureState.Data) { childConstraintWidth = Math.Min(childConstraintWidth, column.DesiredWidth); child.Measure(new Size(childConstraintWidth, constraintHeight)); accumulatedWidth += column.DesiredWidth; } else // ColumnMeasureState.SpecificWidth { childConstraintWidth = Math.Min(childConstraintWidth, column.Width); child.Measure(new Size(childConstraintWidth, constraintHeight)); accumulatedWidth += column.Width; } maxHeight = Math.Max(maxHeight, child.DesiredSize.Height); } // Reset this flag so that we will re-caculate it on every measure. _isOnCurrentPageValid = false; // reserve space for dummy header next to the last column accumulatedWidth += c_PaddingHeaderMinWidth; return(new Size(accumulatedWidth, maxHeight)); }
public static void SetColumnCollection(System.Windows.DependencyObject element, GridViewColumnCollection collection) { }