为什么列表框选择在Windows Phone 7中无法正常工作?

use*_*131 2 windows-phone-7

private void PersonalInfoList_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                System.Collections.IList list = e.AddedItems;
                if (e.AddedItems.Count == 1)
                {
                    IEnumerable<Category> categs = list.Cast<Category>();
                    Category em = categs.ElementAt<Category>(0);
                    int id = em.id;
                    int categoryid = em.categoryid;
                    string subcategoryname = em.subcategname;

                    NavigationService.Navigate(new Uri(String.Format("/SubCategories.xaml?id=" + id + "&categoryid=" + categoryid + "&subcategoryname=" + subcategoryname), UriKind.Relative));
                }
            }
Run Code Online (Sandbox Code Playgroud)

如果列表中有2个项目,如果单击第一个项目然后能够导航到子类别页面.但是再次单击相同的第一个项目无法导航.如果单击第一个项目后单击2项目然后能够导航到子类别页面. ....

Cla*_*sen 5

您需要设置PersonalInfoList.SelectedIndex-1前或者你的电话后,NavigationService.Navigate所选择的项目复位.

如果您使用的是LongListSelector,请将其设置SelectedItemnull