Exemplo n.º 1
0
        // Token: 0x060048D3 RID: 18643 RVA: 0x0014A864 File Offset: 0x00148A64
        public static void OnColumnWidthChanged(IProvideDataGridColumn cell, DependencyPropertyChangedEventArgs e)
        {
            UIElement      uielement = (UIElement)cell;
            DataGridColumn column    = cell.Column;
            bool           flag      = cell is DataGridColumnHeader;

            if (column != null)
            {
                DataGridLength width = column.Width;
                if (width.IsAuto || (!flag && width.IsSizeToCells) || (flag && width.IsSizeToHeader))
                {
                    DataGridLength dataGridLength = (DataGridLength)e.OldValue;
                    double         num;
                    if (dataGridLength.UnitType != width.UnitType)
                    {
                        double constraintWidth = column.GetConstraintWidth(flag);
                        if (!DoubleUtil.AreClose(uielement.DesiredSize.Width, constraintWidth))
                        {
                            uielement.InvalidateMeasure();
                            uielement.Measure(new Size(constraintWidth, double.PositiveInfinity));
                        }
                        num = uielement.DesiredSize.Width;
                    }
                    else
                    {
                        num = dataGridLength.DesiredValue;
                    }
                    if (DoubleUtil.IsNaN(width.DesiredValue) || DoubleUtil.LessThan(width.DesiredValue, num))
                    {
                        column.SetWidthInternal(new DataGridLength(width.Value, width.UnitType, num, width.DisplayValue));
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static void InvalidateElementMeasurePath(UIElement root, UIElement element)
        {
            if (element == null)
            {
                return;
            }

            while (element != root)
            {
                element.InvalidateMeasure();
                element = (UIElement)element.VisualParent;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Invalidates a cell's panel if its column's width changes sufficiently.
        /// </summary>
        /// <param name="cell">The cell or header.</param>
        /// <param name="e"></param>
        public static void OnColumnWidthChanged(IProvideDataGridColumn cell, DependencyPropertyChangedEventArgs e)
        {
            Debug.Assert((cell is DataGridCell) || (cell is DataGridColumnHeader), "provideColumn should be one of the cell or header containers.");

            UIElement      element        = (UIElement)cell;
            DataGridColumn column         = cell.Column;
            bool           isColumnHeader = (cell is DataGridColumnHeader);

            if (column != null)
            {
                // determine the desired value of width for auto kind columns
                DataGridLength width = column.Width;
                if (width.IsAuto ||
                    (!isColumnHeader && width.IsSizeToCells) ||
                    (isColumnHeader && width.IsSizeToHeader))
                {
                    DataGridLength oldWidth     = (DataGridLength)e.OldValue;
                    double         desiredWidth = 0.0;
                    if (oldWidth.UnitType != width.UnitType)
                    {
                        double constraintWidth = column.GetConstraintWidth(isColumnHeader);
                        if (!DoubleUtil.AreClose(element.DesiredSize.Width, constraintWidth))
                        {
                            element.InvalidateMeasure();
                            element.Measure(new Size(constraintWidth, double.PositiveInfinity));
                        }

                        desiredWidth = element.DesiredSize.Width;
                    }
                    else
                    {
                        desiredWidth = oldWidth.DesiredValue;
                    }

                    if (DoubleUtil.IsNaN(width.DesiredValue) ||
                        DoubleUtil.LessThan(width.DesiredValue, desiredWidth))
                    {
                        column.SetWidthInternal(new DataGridLength(width.Value, width.UnitType, desiredWidth, width.DisplayValue));
                    }
                }
            }
        }
Exemplo n.º 4
0
        private static void InvalidateElementMeasurePath(UIElement root, UIElement element)
        {
            if (element == null)
            {
                return;
            }

            while (element != root)
            {
                element.InvalidateMeasure();
                element = (UIElement)element.VisualParent;
            }
        }