2013-09-05 52 views
0

大約三個小時,我一直在嘗試獲取多選列表框的選定索引。我嘗試了各種解決方案,但他們不工作。我發現的最後一件事是:Windows Phone MultiSelect列表框選定的項目

  for (int i = 0; i < this.myListBox.Items.Count; i++) 
      { 
       ListBoxItem currentItem = this.myListBox.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem; 
       if (currentItem != null && currentItem.IsSelected) 
       { 
        ApplicationManager.Instance.getContactManager().addToIndexes(i); 
       } 

      } 

這似乎工作,但當我在列表中向下滾動例如,先前選定項目的listboxitem返回null。我怎樣才能完成這項任務?

+0

你可以使用選定的idex列表框它會爲你工作 – MansinhDodiya

回答

0

按我你的問題的理解,你需要選擇指數...

,所以你必須使用列表框點擊事件,比找到所選指標

例如

private void mylistbox_Tap_1(object sender, System.Windows.Input.GestureEventArgs e) 
     { 


      List<ClsReportId> lstrptId = new List<ClsReportId>(); 
      ListBox lst = (ListBox)sender; 
      int i = lst.SelectedIndex; 
      if (lst.SelectedValue == null) 
      { 
      } 
      else 
      { 
       ClsGetSubmittedReport cls = (ClsGetSubmittedReport)lst.SelectedValue; 
       reportId = cls.ReportId1.ToString(); 


      } 
     } 

希望它會幫助你

謝謝

相關問題