private void Autoscroll(double yVal)
{
double actualPositionPercent = yVal / _scrollViewer.RenderSize.Height * 100;
if (actualPositionPercent < AutoScrollMargin)
{
if (_autoScrollOldYValue >= yVal)
{
ScrollToOffset(AutoScrollOffsetManual * -1);
}
}
else if (actualPositionPercent > 100 - AutoScrollMargin)
{
if (_autoScrollOldYValue <= yVal)
{
ScrollToOffset(AutoScrollOffsetManual);
}
}
_autoScrollOldYValue = yVal;
}