From 3a88d09d149ae5472c3c64de95110414c2532687 Mon Sep 17 00:00:00 2001 From: "jh5.cho" Date: Mon, 26 Dec 2016 17:06:19 +0900 Subject: [PATCH] Fix Scrolling to Specific Element in ScrollView - 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 --- Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs index a566f24..1119538 100755 --- a/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs +++ b/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs @@ -123,7 +123,16 @@ namespace Xamarin.Forms.Platform.Tizen 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); } } -- 2.7.4