+ /// <summary>
+ /// Scroll to specific position with or without animation.
+ /// </summary>
+ /// <param name="position">Destination.</param>
+ /// <param name="animate">Scroll with or without animation</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void ScrollTo(float position, bool animate)
+ {
+ float currentPositionX = mScrollingChild.CurrentPosition.X != 0 ? mScrollingChild.CurrentPosition.X : mScrollingChild.Position.X;
+ float currentPositionY = mScrollingChild.CurrentPosition.Y != 0 ? mScrollingChild.CurrentPosition.Y : mScrollingChild.Position.Y;
+ float delta = ScrollingDirection == Direction.Horizontal ? currentPositionX : currentPositionY;
+ delta -= position;
+
+ ScrollBy(delta, animate);
+ }
+
+ private float BoundScrollPosition(float targetPosition)
+ {
+ if (ScrollAvailableArea != null)
+ {
+ float minScrollPosition = ScrollAvailableArea.X;
+ float maxScrollPosition = ScrollAvailableArea.Y;
+
+ targetPosition = Math.Min(-minScrollPosition, targetPosition);
+ targetPosition = Math.Max(-maxScrollPosition, targetPosition);
+ }
+ else
+ {
+ targetPosition = Math.Min(0, targetPosition);
+ targetPosition = Math.Max(-maxScrollDistance, targetPosition);
+ }
+
+ return targetPosition;
+ }
+