This project is read-only.
1
Vote

FlipViewPanoramaBehavior throws an exception with mouse input w/ 4+ items

description

SizePosFlipViewItems() makes the assumption that the items returned by GetFlipViewItems() corresponds to the FlipView's Items property. This only seems to be the case once the users uses touch input to control the FlipView; if you only use mouse input, it'll only contain three at a time, meaning when you try to navigate to the fourth item, it'll generate an out of bounds exception (since FlipView.SelectedIndex will be 3, and the items list ends at 2).

Solution is to replace:

var selectedIndex = AssociatedObject.SelectedIndex;

With:

int currentIndex = -1;
for (int i = 0; i < items.Count; i++)
{
if (items[i].Content == AssociatedObject.SelectedItem)
{
    currentIndex = i;
    break;
}
}
var selectedIndex = currentIndex;

if (selectedIndex == -1)
return;

comments