/// <summary> /// Calculate the extent of the view based on the available size /// </summary> /// <param name="availableSize">available size</param> /// <param name="itemCount">number of data items</param> /// <returns></returns> private System.Windows.Size CalculateExtent(System.Windows.Size availableSize, int itemCount) { if (PageRowBounds == null || PageRowBounds.Length == 0) { return(new Size(availableSize.Width, _extent.Height)); } // we get the pdf page with the greatest width, so we know how broad the extent must be var maxWidth = PageRowBounds.Select(f => f.Width).Max(); // we get the sum of all pdf page heights, so we know how high the extent must be var totalHeight = PageRowBounds.Sum(f => f.Height); return(new Size(maxWidth, totalHeight)); }
public double GetVerticalOffsetByItemIndex(int itemIndex) { // sum the heights of all previous pages: this is where the current y offset should be return(PageRowBounds.Take(itemIndex).Sum(f => f.Height)); }