void SetIndicators() { if (Element.ShowIndicators) { SetPosition(); indicators.SetViewPager(viewPager); // IndicatorsTintColor BP indicators.SetFillColor(Element.IndicatorsTintColor.ToAndroid()); // CurrentPageIndicatorTintColor BP indicators.SetPageColor(Element.CurrentPageIndicatorTintColor.ToAndroid()); // IndicatorsShape BP indicators.SetStyle(Element.IndicatorsShape); // Rounded or Squared } else { indicators.RemoveAllViews(); } // ShowIndicators BP indicators.Visibility = Element.ShowIndicators? AViews.ViewStates.Visible : AViews.ViewStates.Gone; }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); var rect = this.Element.Bounds; switch (e.PropertyName) { case "Orientation": if (Element != null) { SetNativeView(); Element.PositionSelected?.Invoke(Element, Element.Position); } break; case "InterPageSpacing": //var metrics = Resources.DisplayMetrics; //var interPageSpacing = Element.InterPageSpacing * metrics.Density; //viewPager.PageMargin = (int)interPageSpacing; break; case "BackgroundColor": viewPager?.SetBackgroundColor(Element.BackgroundColor.ToAndroid()); break; case "IsSwipingEnabled": SetIsSwipingEnabled(); break; case "IndicatorsTintColor": indicators?.SetFillColor(Element.IndicatorsTintColor.ToAndroid()); break; case "CurrentPageIndicatorTintColor": indicators?.SetPageColor(Element.CurrentPageIndicatorTintColor.ToAndroid()); break; case "IndicatorsShape": indicators?.SetStyle(Element.IndicatorsShape); break; case "ShowIndicators": SetIndicators(); break; case "ItemsSource": if (Element != null && viewPager != null) { SetPosition(); viewPager.Adapter = new PageAdapter(Element); viewPager.SetCurrentItem(Element.Position, false); indicators?.SetViewPager(viewPager); Element.PositionSelected?.Invoke(Element, Element.Position); if (Element.ItemsSource != null && Element.ItemsSource is INotifyCollectionChanged) { ((INotifyCollectionChanged)Element.ItemsSource).CollectionChanged += ItemsSource_CollectionChanged; } } break; case "ItemTemplate": if (Element != null && viewPager != null) { viewPager.Adapter = new PageAdapter(Element); viewPager.SetCurrentItem(Element.Position, false); indicators?.SetViewPager(viewPager); Element.PositionSelected?.Invoke(Element, Element.Position); } break; case "Position": if (Element != null && !isSwiping) { SetCurrentPage(Element.Position); } break; } }