summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS/Renderers/CarouselPageRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/Renderers/CarouselPageRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/CarouselPageRenderer.cs22
1 files changed, 13 insertions, 9 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/CarouselPageRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/CarouselPageRenderer.cs
index 16e97cd2..6e7c6b2a 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/CarouselPageRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/CarouselPageRenderer.cs
@@ -37,11 +37,15 @@ namespace Xamarin.Forms.Platform.iOS
WantsFullScreenLayout = true;
}
+ IElementController ElementController => Element as IElementController;
+
protected CarouselPage Carousel
{
get { return (CarouselPage)Element; }
}
+ IPageController PageController => (IPageController)Element;
+
protected int SelectedIndex
{
get { return (int)(_scrollView.ContentOffset.X / _scrollView.Frame.Width); }
@@ -98,7 +102,7 @@ namespace Xamarin.Forms.Platform.iOS
return;
_appeared = true;
- Carousel.SendAppearing();
+ PageController.SendAppearing();
}
public override void ViewDidDisappear(bool animated)
@@ -109,7 +113,7 @@ namespace Xamarin.Forms.Platform.iOS
return;
_appeared = false;
- Carousel.SendDisappearing();
+ PageController.SendDisappearing();
}
public override void ViewDidLayoutSubviews()
@@ -139,9 +143,9 @@ namespace Xamarin.Forms.Platform.iOS
View.Add(_scrollView);
- for (var i = 0; i < Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- Element element = Element.LogicalChildren[i];
+ Element element = ElementController.LogicalChildren[i];
var child = element as ContentPage;
if (child != null)
InsertPage(child, i);
@@ -199,7 +203,7 @@ namespace Xamarin.Forms.Platform.iOS
if (_appeared)
{
_appeared = false;
- Carousel.SendDisappearing();
+ PageController?.SendDisappearing();
}
if (_events != null)
@@ -266,10 +270,10 @@ namespace Xamarin.Forms.Platform.iOS
void OnDecelerationEnded(object sender, EventArgs eventArgs)
{
- if (_ignoreNativeScrolling || SelectedIndex >= Element.LogicalChildren.Count)
+ if (_ignoreNativeScrolling || SelectedIndex >= ElementController.LogicalChildren.Count)
return;
- Carousel.CurrentPage = (ContentPage)Element.LogicalChildren[SelectedIndex];
+ Carousel.CurrentPage = (ContentPage)ElementController.LogicalChildren[SelectedIndex];
}
void OnPagesChanged(object sender, NotifyCollectionChangedEventArgs e)
@@ -335,9 +339,9 @@ namespace Xamarin.Forms.Platform.iOS
{
Clear();
- for (var i = 0; i < Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- Element element = Element.LogicalChildren[i];
+ Element element = ElementController.LogicalChildren[i];
var child = element as ContentPage;
if (child != null)
InsertPage(child, i);