Windows phone 7 Windows Phone 7中的列表框菜单

Windows phone 7 Windows Phone 7中的列表框菜单,windows-phone-7,Windows Phone 7,你好, 我想在WindowsPhone7中创建一个动态填充的菜单。我认为列表框最适合这样做。但是,一旦用户与列表框交互,我就无法获取“selectedValue”,因此我无法向navigationhandler提供任何信息 如何创建一个ListBox,动态创建其ListBox项,并使用不同的参数(例如 \informations.xam?id=2不久前,我编写了一个WP7应用程序,并使用了如下内容: private void CategoryList_SelectionChanged(objec

你好, 我想在WindowsPhone7中创建一个动态填充的菜单。我认为列表框最适合这样做。但是,一旦用户与列表框交互,我就无法获取“selectedValue”,因此我无法向navigationhandler提供任何信息

如何创建一个ListBox,动态创建其ListBox项,并使用不同的参数(例如


\informations.xam?id=2

不久前,我编写了一个WP7应用程序,并使用了如下内容:

private void CategoryList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (CategoryList.SelectedIndex == -1) return;
    string id = (CategoryList.SelectedItem as DepartmentViewModel).ID;
    NavigationService.Navigate(new Uri("/Views/CatalogueBrowser/CategoriesPage.xaml?deptId=" + id, UriKind.Relative));
    CategoryList.SelectedIndex = -1;
}

基本上,我将listbox的itemssource设置为特定视图模型的可观察集合,然后您只需使用listbox的SelectedItem属性访问选定的视图模型对象。

不久前,我编写了一个WP7应用程序,我使用了如下内容:

private void CategoryList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (CategoryList.SelectedIndex == -1) return;
    string id = (CategoryList.SelectedItem as DepartmentViewModel).ID;
    NavigationService.Navigate(new Uri("/Views/CatalogueBrowser/CategoriesPage.xaml?deptId=" + id, UriKind.Relative));
    CategoryList.SelectedIndex = -1;
}

基本上,我将listbox的itemssource设置为特定视图模型的可观察集合,然后您只需使用listbox的SelectedItem属性访问所选视图模型对象。

创建一个新的“Windows Phone数据绑定应用程序”作为项目一部分生成的样板代码将向您展示如何做到这一点。

创建一个新的“Windows Phone数据绑定应用程序”,作为项目一部分生成的样板代码将向您展示如何做到这一点。

请注意,选择设置回-1,这是一个重要的细节。(如果您不这样做,然后导航回,单击同一项将不起任何作用,因为选择没有“更改”),请注意,选择设置回-1,这是一个重要的细节。(如果您不这样做,然后导航回,单击同一项目将不起任何作用,因为选择没有“更改”)