So I have this listbox with the ItemSource of a ObservableCollection And let's say I add 2 items to the listbox then the ObservableCollection contains 2 strings right?
Now.. I'm trying to create a messagebox popup containing whatevers in the string. So let's say I have a listbox with 2 items, Cat & Bob.
Now when I press I button I want it to prompt me with two messageBoxes, one saying Cat & one saying bob. I tried doing a foreach statement but it doesnt want to execute when I press the button. Now.. The ObservableCollection is in 1 Window and the button I press is in another window so im not sure if that makes a difference.
So what I did is I declared the other window at the top of this one like so..
People peps = new People();
foreach(string email in peps.recipients)
{
if (comboBox1.Text == "Email")
{
MessageBox.Show(peps.Listbox1.Items.ToString());
MessageBox.Show(peps.Listbox1.Items.ToString());
}
}
But it's not printing out anything.
How do I make the messageboxes show whatever is in the Listbox1