public void UpdateHeight(ScrollBar bar, Contents contents) { //var scrollTrackSpace = self.contentHeight - self.viewportHeight; // (600 - 200) = 400 //var scrollThumbSpace = self.viewportHeight - self.thumbHeight; // (200 - 50) = 150 //var scrollJump = scrollTrackSpace / scrollThumbSpace; // (400 / 150 ) = 2.666666666666667 float viewportHeight = bar.Height; float contentHeight = contents.CalcTotalHeight(); float pct = viewportHeight / contentHeight; // Bar height == panel height - drag bounds if (pct < (float)0.98) { var height = Math.Floor(bar.Height * pct); if (height != _height) { _height = (int)height; DragAreaOffset = new Rectangle(DragAreaOffset.X, DragAreaOffset.Y, Width, Height); //TODO: Need to recalculate where we should be based on the new height } } }