- Add the calculation code for getting coordination of given Element
: ScrollToAsync() which has Element parameter did not work.
It always scroll to (0,0) because there were no calculation code for Element.
TASK=TCAPI-2174
Change-Id: I6f3fbdbd060b1c74bc89c25e7e46d99cf10fbf51
void ScrollRequestHandler(object sender, ScrollToRequestedEventArgs e)
{
- Rect region = new Rect(ToNativeDimension(e.ScrollX), ToNativeDimension(e.ScrollY), ToNativeDimension(Element.Width), ToNativeDimension(Element.Height));
+ var x = e.ScrollX;
+ var y = e.ScrollY;
+ if (e.Mode == ScrollToMode.Element)
+ {
+ Point itemPosition = (Element as IScrollViewController).GetScrollPositionForElement(e.Element as VisualElement, e.Position);
+ x = itemPosition.X;
+ y = itemPosition.Y;
+ }
+
+ Rect region = new Rect(ToNativeDimension(x), ToNativeDimension(y), ToNativeDimension(Element.Width), ToNativeDimension(Element.Height));
Control.ScrollTo(region, e.ShouldAnimate);
}
}