1
votes
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!!

1
Please provide at least some code, that reproduces your problem. Answering this question will result in wild guesses - Jehof
@Jaihind I meant to say that, if I select item number 1 in listbox, then how to deselect that item automatically, because that item is already selected, so I am not able to select that item. - Viraj Shah
is there listbox selection change event in your code ??? - Jaihind
@Jaihind yes, there is - Viraj Shah
@VirajShah share ListBox selectionchanged event code. - Jaihind

1 Answers

1
votes

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