【问题标题】:Windows Phone MultiSelect ListBox selected itemsWindows Phone MultiSelect ListBox 所选项目
【发布时间】:2013-09-05 12:38:12
【问题描述】:

大约三个小时以来,我一直在尝试获取多选列表框的选定索引。我尝试了各种解决方案,但它们不起作用。我发现的最后一件事如下;

            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。我怎样才能完成这项任务?

【问题讨论】:

  • 您可以使用列表框的选定索引,它将为您工作

标签: windows-phone-8 listbox listboxitem


【解决方案1】:

根据我对您问题的理解,您需要选择索引...

所以你必须使用列表框点击事件而不是找到选定的索引

例如

  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();


            }
        }

希望对你有帮助

谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-12
    • 1970-01-01
    • 2011-10-03
    • 1970-01-01
    相关资源
    最近更新 更多