问题描述
我使用的是 FlipView
建设一个照片应用程序。在BottomAppBar,我放在的ListView
所有的图像,以便能够在 FlipView
时查看图像I双击它,在的ListView
并获得中显示的图像 FlipView
在的ListView选择
(如分页)。
I'm building a Photo app using a FlipView
. In the BottomAppBar, I placed a ListView
of all the images to be able to view the image in the FlipView
when I click it in the ListView
and get the image displayed in the FlipView
, selected in the ListView
(like a Pagination).
在 listView.selectionChanged
时,我做了code,显示在图像的 FlipView
当我在 ListView中选中它
。这里是code:
In the listView.selectionChanged
event, I made the code that shows the image in the FlipView
when I select it in the 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;
}
}
}
现在,当我需要的 listView.SelectedIndex
根据修改 flipView.SelectedIndex
Now when I need to change the listView.SelectedIndex
according to the flipView.SelectedIndex
listView.SelectedIndex = flipView.SelectedIndex
我有一个例外:
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.
我需要能够获得在 FlipView
,选择并scrollAt它在的ListView
...
I need to be able to get the same image selected in the FlipView
, selected and scrollAt it in the ListView
...
推荐答案
我最终使它通过增加工作我的 FlipView
:
I ended up making it work by adding to my FlipView
:
SelectedIndex="{Binding Path=SelectedIndex, ElementName=listView1, Mode=TwoWay}"
和我的的ListView
:
SelectedIndex="{Binding Path=SelectedIndex, ElementName=flipView1, Mode=TwoWay}"
他们都的SelectedIndex
称对方!
这篇关于设置的ListView的SelectedIndex在FlipView_SelectionChanged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!