Esempio n. 1
0
        /// <summary>
        /// 为给定的覆盖单元格和行索引获取RowSpan
        /// Get RowSpan for the given covered cell and rowIndex
        /// </summary>
        /// <param name="currHeaderCell"></param>
        /// <param name="rowindex"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static int GetHeightIncrementationLimit(this SfDataGrid sfGrid, CoveredCellInfo currHeaderCell, int rowindex)
        {
            if (rowindex < 0 || sfGrid.RowGenerator.Items.Count == 0)
            {
                return(0);
            }

            int incrementHeightLevel = 0;
            var prevHeaderCells      = (sfGrid.RowGenerator.Items.FirstOrDefault(row => row.RowIndex == rowindex) as SpannedDataRow).CoveredCells;
            int index = -1;

            foreach (var prevCell in prevHeaderCells)
            {
                //WPF-24997 We need to skip certain covered cells from setting height level which is not deals previous covered cells.
                //Hence the below condition is added by comparing the left and right indexes of Current and Previous covered cells.
                index++;
                if ((prevCell.Left <= currHeaderCell.Right && prevCell.Right >= currHeaderCell.Left) || (prevCell.Left >= currHeaderCell.Right && prevCell.Right <= currHeaderCell.Left))
                {
                    break;
                }

                //if (prevHeaderCells.IndexOf(prevCell) == prevHeaderCells.Count - 1)
                if (index == prevHeaderCells.Count - 1)
                {
                    incrementHeightLevel++;
                    incrementHeightLevel += sfGrid.GetHeightIncrementationLimit(currHeaderCell, rowindex - 1);
                    break;
                }
            }

            if (prevHeaderCells.Count == 0)
            {
                incrementHeightLevel++;
                incrementHeightLevel += sfGrid.GetHeightIncrementationLimit(currHeaderCell, rowindex - 1);
            }

            return(incrementHeightLevel);
        }