Skip to content

Instantly share code, notes, and snippets.

@chrisriesgo
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisriesgo/2ba8873db358131d0b8d to your computer and use it in GitHub Desktop.
Save chrisriesgo/2ba8873db358131d0b8d to your computer and use it in GitHub Desktop.
void ItemsSourceChanged ()
{
if (ItemsSource == null) return;
var countDelta = ItemsSource.Count - Children.Count;
if (countDelta > 0) {
for (var i = 0; i < countDelta; i++)
{
CreateDot();
}
}
else if (countDelta < 0)
{
for (var i = 0; i < -countDelta; i++)
{
Children.RemoveAt (0);
}
}
}
public PagerIndicatorDots()
{
HorizontalOptions = LayoutOptions.CenterAndExpand;
VerticalOptions = LayoutOptions.Center;
Orientation = StackOrientation.Horizontal;
DotColor = Color.Black;
}
void CreateDot()
{
//Make one button and add it to the layout
var dot = new Button {
BorderRadius = Convert.ToInt32(DotSize/2),
HeightRequest = DotSize,
WidthRequest = DotSize,
BackgroundColor = DotColor
};
Children.Add(dot);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment