2011-08-31 2 views
1

목록 상자가 있는데 목록 항목을 클릭하면 세부 정보 페이지로 이동합니다. 세부 정보 페이지에서 뒤로 키를 누른 다음 다시 키를 누르면 판매 목록 항목은 세부 정보 페이지로 이동하지 않지만 목록의 다른 항목을 클릭하면 해당 세부 정보 페이지로 이동합니다. 실제로 나는 뒤로 키를 눌렀을 때 목록 상자를 다시로드하지 않습니다. 목록 상자를 다시로드하면 뒤의 stack.if에서 팝업됩니다. 문제는 없습니다.이 문제의 해결책은 무엇입니까.뒤로 키를 사용하여 탐색 할 때 목록 상자 항목 문제

ListViewPage

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) 
{ 
    if (DetailPage.isBackkeyPressed && list != null) 
    { 
     DetailPage.isBackkeyPressed = false; 
    } 
    else 
    { 
     ListDetails(); //Reloading the page if list is empty 
    } 

    base.OnNavigatedTo(e); 
} 

private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) 
{ 
    if (listBox.SelectedIndex >= 0) 
    { 
     (Application.Current as App).obj_list = list[listBox.SelectedIndex]; 
     NavigationService.Navigate(new Uri("/DetailPage.xaml", UriKind.Relative)); //Navigate to detail page 
    } 
} 

DetailPage 당신은 다음과 같이 -1로 설정하여 SelectedIndex 설정을 해제 할 필요가

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) 
{ 
    isBackkeyPressed = true;//flag for check if back key is pressed 
    base.OnBackKeyPress(e); 
} 

답변

2

:

private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) 
{ 
    if (listBox.SelectedIndex >= 0) 
    { 
     (Application.Current as App).obj_list = list[listBox.SelectedIndex]; 
     NavigationService.Navigate(new Uri("/DetailPage.xaml", UriKind.Relative)); //Navigate to detail page 

     listBox.SelectedIndex = -1; 
    } 
} 
+1

를 각 항목에 탭 이벤트를 처리 SelectionChanged를 처리하는 대신 ItemTemplate에서 설정합니다. –

+0

Claus 지금 고마워요. – Sujiz

+0

탭 처리기에 대한 명령 바인딩을 수행 할 수 없습니다 ;-) (그러나 ToolkitExtensions http://nuget.org/List/Packages/ToolkitExtensions와 함께 SelectionChanged에 대해) –