I'm having a problem in the development of a windows phone 8.1 app. The app in question presents a page that displays a listView
. via a button in the appbar.
I switch from single to multiple selection (with checkboxes), and pressing the back_button returns to the default selection (as the messages app in windows phone).
Everything works correctly when I open the app, but if I navigate to other pages and then return to the page described above, then nothing works as it should.
The first function sets multiple selections. However, if I press the back button ( I'm in App7.MainPage) then the test MyListview.selectionmode == ListViewSelectionMode.none
returns true
.
public void MultiSelButton_Click(object sender, RoutedEventArgs e)
{
MyListview.SelectionMode = ListViewSelectionMode.Multiple;
BottomAppBar = appbars.MultiSelBar;
}
void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
String sourcepage = null;
if (rootFrame != null)
{
sourcepage = rootFrame.CurrentSourcePageType.ToString();
switch (sourcepage)
{
case "App7.MainPage":
if (MyListview.SelectionMode == ListViewSelectionMode.None)
{
rootFrame.BackStack.Clear();
return;
}
torna_single();
break;
case "App7.Cerca":
Frame.Navigate(typeof(MainPage));
break;
case "App7.InserisciLeggiNota":
if (Frame.CanGoBack)
Frame.GoBack();
break;
}
e.Handled = true;
}
}