1
votes

How do I get the listbox selected value and listpicker selected value in OnNavigated method, I have list picker and listbox binded with items that come from web service response, I know how to get listbox and list picker selected value in selection changed event, but how do I get those values in other events? Thanks!!

void client_live_permissionCompleted(object sender, ServiceReference1.live_permissionCompletedEventArgs e)
    {
      LIST data = (sender as ListBox).SelectedItem as LIST;
        long id = data.Id;
        string name = data.Name;
    }

but I debug it, it is showing error.

1
Name the ListBox in the xaml and then use it in the code behind.bit
Share some code, where you want to selected valueJaihind
@Jaihind see my code and help me.ThanksViraj Shah
@bit but I want the id also in the back end from listbox selection. ThanksViraj Shah
@VirajShah Yes, that is what I suggested you. In your Xaml name it to listbox1, then use listbox1 directly in the code behind..bit

1 Answers

2
votes

This may help you, let me know if doesn't work.

void client_live_permissionCompleted(object sender, ServiceReference1.live_permissionCompletedEventArgs e)
        {
          //var selectedItem = listBox or listicker.SelectedItem as yourType
            LIST data = YourListBox.SelectedItem as LIST;
            long id = data.Id;
            string name = data.Name;
        }