【问题标题】:ListBox selection issue in Windows PhoneWindows Phone 中的列表框选择问题
【发布时间】:2014-03-31 06:34:02
【问题描述】:
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (listBox1.SelectedItem == null)
            return;

        LIST data = (sender as ListBox).SelectedItem as LIST;
        string result = data.item.ToString();
    }

我在 Windows Phone 中的列表框选择有问题,我已将列表框的选择模式设置为“多个”, 但问题是我的手机应用程序页面中有列表选择器和列表框, 我正在选择第一个列表框项目并选择列表选择器项目, 现在我无法选择我之前选择的列表框项目, 如何解决? 如果我选择其他项目,那么我可以在列表框中选择以前选择的项目。 谢谢!!

【问题讨论】:

  • 请至少提供一些代码,以重现您的问题。回答这个问题会引起疯狂的猜测
  • @Jaihind 我的意思是说,如果我在列表框中选择项目编号 1,那么如何自动取消选择该项目,因为该项目已被选中,所以我无法选择该项目。
  • 您的代码中是否有列表框选择更改事件???
  • @Jaihind 是的,有
  • @VirajShah 分享 ListBox selectionchanged 事件代码。

标签: c#-4.0 windows-phone-8 listboxitem


【解决方案1】:

希望这会对你有所帮助。

private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if(listBox1.SelectedIndex==-1)
           return;
        if (listBox1.SelectedItem == null)
            return;

        LIST data = (sender as ListBox).SelectedItem as LIST;
        string result = data.item.ToString();
          listBox1.SelectedIndex = -1;
    }

【讨论】:

  • 谢谢你兄弟..你又为我做了..继续努力..上帝保佑
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-30
  • 1970-01-01
相关资源
最近更新 更多