I Have list on images that i display in listview. When i click listview item it opens another page where it shows bigger version of current picture. When i press Windows phone back button i would like listview to scroll to the item that was selected earlier.
Here is how I save lsitview.selectedindex:
private void NavigationHelper_SaveState(object sender, SaveStateEventArgs e)
{
e.PageState.Add("id", listview.SelectedIndex);
}
This is how i am trying set listview:
private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
if (null != e.PageState && e.PageState.ContainsKey("id"))
{
int i = (int)e.PageState["id"];
listview.ScrollIntoView(listview.Items[i]);
System.Diagnostics.Debug.WriteLine(listview.Items.Count);
}
}
I also tried like this but this is not working ?
private void listview_Loaded(object sender, RoutedEventArgs e)
{
listview.ScrollIntoView(listview.Items[i])
}
But when i add normal button to my lisview page like this:
private void Button_Click(object sender, RoutedEventArgs e)
{
listview.ScrollIntoView(listview.Items[i]);
}
It scroll to selected item after button click. How i can make it work without button so that lisview scroll automatically last selected item?
`