C# 如何在单击列表框中的项目时导航到新页面
我正在windows phone 7中构建一个应用程序,单击列表框中的某个项目时,我需要导航到一个新页面 我的xaml代码是:C# 如何在单击列表框中的项目时导航到新页面,c#,listbox,C#,Listbox,我正在windows phone 7中构建一个应用程序,单击列表框中的某个项目时,我需要导航到一个新页面 我的xaml代码是: <ListBox Name="listBox1" SelectionChanged="listBox1_SelectionChanged" Height="676" VerticalAlignment="Bottom"> 我想导航到NewsDetails页面。但在这里,当我点击列表框中的一个项目时,什么都没有发生。有人能帮我做这件事吗?是否调用了列表框1
<ListBox Name="listBox1" SelectionChanged="listBox1_SelectionChanged" Height="676" VerticalAlignment="Bottom">
我想导航到NewsDetails页面。但在这里,当我点击列表框中的一个项目时,什么都没有发生。有人能帮我做这件事吗?是否调用了
列表框1\u selection changed
?如果没有,请确保没有捕获列表框项目中触摸事件的按钮或其他控件
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// If selected index is -1 (no selection) do nothing
if (listBox1.SelectedIndex == -1)
return;
// Navigate to the new page
NavigationService.Navigate(new Uri("/NewsDetails.xaml?selectedItem=" + listBox1.SelectedIndex, UriKind.Relative));
// Reset selected index to -1 (no selection)
listBox1.SelectedIndex = -1;
}