How to set Page Navigation from Listbox to another Page?

后端 未结 3 1857
情话喂你
情话喂你 2020-12-21 14:20

Hi am using XAML file given below.I want to Navigate Listbox selected item to another page.

 

        
3条回答
  •  不思量自难忘°
    2020-12-21 14:28

    In the SelectionChanged event handler of ListBox,, add this line

    override NotchsList11_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var item = NotchsList11.Items[NotchsList11.SelectedIndex] as YourClassUsedForBinding;
            if(item.SomeProperty == "Something")
            NavigationService.Navigate(new Uri("/YourNewPage.xaml", UriKind.Relative));
            else
            NavigationService.Navigate(new Uri("/YourOtherPage.xaml", UriKind.Relative));
            //if more cases use a switch case
        }
    

提交回复
热议问题