ListBox で 1 つの項目が選択されると、selectedindex の記録が保持されます。同じ要素が再度タップされた場合、selectedindex は変更されないため、SelectionChanged は発生しません。したがって、選択するたびに、またはリストボックスページに戻るナビゲーションの後に、selectedindex を -1 に戻すことができます。
//In the onnavigatedto function, set the listbox selectedindex to -1
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
MyListBox.SelectedIndex = -1;
}
そして、selectionchanged イベントを次のように変更します
private void MyListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//let our code run only if index is not -1
if (MyListBox.SelectedIndex != -1)
{
//Your selectionchanged code
}
}
お役に立てれば
更新: パノラマの場合
private void MyListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox listbox = (sender as ListBox);
//let our code run only if index is not -1
if (listbox.SelectedIndex != -1)
{
//Your selectionchanged code
At the end of it set the index back to -1
listbox.SelectedIndex = -1;
}
}