void SetupVerticalScrollRelation() { this.scBar.SetCustomScrollBarEvaluator((SliderBox sc, out double onePixelFor, out int scrollBoxLength) => { int physicalScrollLength = sc.PhysicalScrollLength; onePixelFor = 1; scrollBoxLength = 1; //1. int contentLength = scrollableSurface.DesiredHeight; if (contentLength == 0) { return; } scrollBoxLength = (int)((physicalScrollLength * scrollableSurface.ViewportHeight) / contentLength); if (scrollBoxLength < sc.ScrollBoxSizeLimit) { scrollBoxLength = sc.ScrollBoxSizeLimit; onePixelFor = (double)contentLength / (double)(physicalScrollLength - scrollBoxLength); } else { onePixelFor = (double)contentLength / (double)physicalScrollLength; } //temp fix sc.MaxValue = (contentLength > scrollableSurface.ViewportHeight) ? contentLength - scrollableSurface.ViewportHeight : 0; }); //-------------------------------------------------------------------------------------- //1st evaluate scBar.MaxValue = scrollableSurface.DesiredHeight; scBar.ReEvaluateScrollBar(); scrollableSurface.LayoutFinished += (s, e) => { scBar.MaxValue = scrollableSurface.DesiredHeight; scBar.ReEvaluateScrollBar(); }; scBar.UserScroll += (s, e) => { scrollableSurface.SetViewport(scrollableSurface.ViewportX, (int)scBar.ScrollValue); }; }
//--------------------------------------------------------------------------- //vertical scrollbar public void ReEvaluateScrollBar() { slideBox.ReEvaluateScrollBar(); }