Scrollbar limits

So I was looking for a way to add a scrollbar for my Scrollview Stackpanels.
I used this example:

And it worked relatively fine, except the scrollbar is not limited to the parent/panel in which it is located. If I use the example exactly when the Scrollview is scrolled down the scrollbar goes outside the bounds of the panel which contains it.

Also I don`t really see what is the use of the anchor property for the scrollbar in this example.

Ok, as always figured it out just when I thought I had tried everything. So in the example the target is moved along the Y axis with the ratio of 1, if it is reduced (for example 0.95 or 0.97) the scrollbar stays within bounds, which makes sense.