I am creating a Photos application using FlipView. In the BottomAppBar, I placed ListViewall the images in order to be able to view the image in FlipViewwhen I click it in ListViewand get the image displayed in the FlipViewone selected in ListView(e.g. pagination).
In the event, listView.selectionChangedI made code that displays the image in FlipView, when I select it in ListView. Here is the code:
private void listView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
string CurrentViewState = ApplicationView.GetForCurrentView().Orientation.ToString();
int IndicatorIndex = listView.SelectedIndex;
GoToPage(CurrentViewState, IndicatorIndex);
}
private void GoToPage(string CurrentViewState, int IndicatorIndex)
{
if (CurrentViewState == "Portrait")
{
flipView1.SelectedIndex = IndicatorIndex;
}
else if (CurrentViewState == "Landscape")
{
if (IndicatorIndex % 2 == 0)
flipView1.SelectedIndex = IndicatorIndex / 2;
else
{
if (IndicatorIndex == 1)
flipView1.SelectedIndex = 1;
else
flipView1.SelectedIndex = (IndicatorIndex + 1) / 2;
}
}
}
Now that I need to change listView.SelectedIndexaccording toflipView.SelectedIndex
listView.SelectedIndex = flipView.SelectedIndex
I have an exception:
An exception of type 'System.ArgumentException' occurred in eBookApp.exe but was not handled in user code. Additional information: Value does not fall within the expected range.
I need to get the same image selected in FlipView, selected and scrollable in ListView...