public PagesViewModel(double height)
{
ScreenHeight = height;
int j = 0;
int itemsPerPage = (int)(height / 80) * 4;
int temp = itemsPerPage;
CarouselPages = new ObservableCollection<List<Contacts>>();
var contactsviewmodel = new ContactsViewModel();
var count = GetPageCount(height, contactsviewmodel.ContactsInfo.Count, itemsPerPage);
for (int i = 0; i < count; i++)
{
var source = contactsviewmodel.ContactsInfo.Skip(j).Take(temp);
var items = source.AsEnumerable().ToList().ToList();
CarouselPages.Add(items);
j += itemsPerPage;
}
}
private int GetPageCount(double height, int count, int itemsperpage)
{
int i = 0;
int itemscount = 0;
while (itemscount <= count)
{
itemscount += itemsperpage;
i++;
}
return i;
}
|