protected override void OnElementChanged(ElementChangedEventArgs <CarouselPage> e) { if (NativeView == null) { _outterLayout = new Native.ApplicationLayout(Forms.NativeParent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; _outterLayout.Show(); _index = new Index(Forms.NativeParent) { IsHorizontal = true, AutoHide = false, }; _index.Changed += OnIndexChanged; _index.Show(); _outterLayout.SetContentPart(_index); _scroller = new Scroller(Forms.NativeParent) { HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible, VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible, HorizontalPageScrollLimit = 1, PageWidth = 1, PageHeight = 1, AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; _scroller.PageScrolled += OnPageScrolled; _scroller.Show(); _innerContainer = new Box(Forms.NativeParent) { AlignmentX = -1, AlignmentY = -1, WeightX = 1, WeightY = 1, }; _innerContainer.SetLayoutCallback(OnInnerLayoutUpdate); _innerContainer.Show(); _scroller.SetContent(_innerContainer); _outterLayout.SetBackgroundPart(_scroller); SetNativeView(_outterLayout); } if (e.OldElement != null) { e.OldElement.CurrentPageChanged -= OnCurrentPageChanged; e.OldElement.PagesChanged -= OnPagesChanged; _isInitalized = false; } if (e.NewElement != null) { Element.CurrentPageChanged += OnCurrentPageChanged; Element.PagesChanged += OnPagesChanged; } base.OnElementChanged(e); }