Question

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

I am having problem with listbox selection in Windows Phone, I have set selection mode of Listbox to "Multiple", but problem is that I have listpicker and listbox in my phone application page, I am selecting first listbox item and selecting list picker item, now I am not able to select that item of listbox that I have selected previously, how to solve it? If I select other item, then I am able to select previously selected item in listbox. Thanks!!

Was it helpful?

Solution

May this will help you.

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;
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top