Hi,
In the xamShowCase, in the music player, you use the following method "GetCenterPositionOffset" to put a album cover in the front :
But in this method you use "viewSettings.ItemsPerPage" to know the number of items !
In a real application, we have [0,viewSettings.ItemsPerPage] items displayed ! If we only have 3 items when ItemsPerPage= 10, the calculation is wrong.
We need a way to know the "current number of visible items" ! So, how can we have this information ?
Thanks
private int GetTotalVisibleItems(XamDataCarousel xamDataCarousel)
{
int firstVisibleItemIndex = (int)xamDataCarousel.ScrollInfo.VerticalOffset; if (xamDataCarousel.ViewableRecords.Count <= xamDataCarousel.ViewSettings.ItemsPerPage) return xamDataCarousel.ViewableRecords.Count - Math.Abs(firstVisibleItemIndex); else if (firstVisibleItemIndex < 0) return xamDataCarousel.ViewSettings.ItemsPerPage - Math.Abs(firstVisibleItemIndex); else return Math.Min(xamDataCarousel.ViewSettings.ItemsPerPage, xamDataCarousel.ViewableRecords.Count - firstVisibleItemIndex); }
int firstVisibleItemIndex = (int)xamDataCarousel.ScrollInfo.VerticalOffset;
if (xamDataCarousel.ViewableRecords.Count <= xamDataCarousel.ViewSettings.ItemsPerPage)
return xamDataCarousel.ViewableRecords.Count - Math.Abs(firstVisibleItemIndex);
else if (firstVisibleItemIndex < 0)
return xamDataCarousel.ViewSettings.ItemsPerPage - Math.Abs(firstVisibleItemIndex);
else
return Math.Min(xamDataCarousel.ViewSettings.ItemsPerPage, xamDataCarousel.ViewableRecords.Count - firstVisibleItemIndex);
}