Сохранение элементов списка даже после закрытия формы в C#, WPF
I have a listbox in which i am adding items from the textbox by clicking a button. What i want is even when i close the form every time when i open the form the list should be displayed which is present or saved earlier in the listbox. I am unable to display the list in the listbox when the form is closed.
Что я уже пробовал:
Добавить Btton :
private void Add_PhoneNumber_Click(object sender, RoutedEventArgs e) { string Country_Code = "+91"; ListBox_PhnNumbr.Items.Add(Country_Code + Phone); MessageBox.Show(String.Format("Phone Number : {0}{1} is Added to List", Country_Code, Phone)); } SAVE Button : <pre>private SOTA_whitelist_Number RetrieveSOTAConfiguration() { string Number1 = string.Empty; string Number2 = string.Empty; string Number3 = string.Empty; string Number4 = string.Empty; string Number5 = string.Empty; if (ListBox_PhnNumbr.Items.Count > 0) Number1 = ListBox_PhnNumbr.Items[0].ToString(); if (ListBox_PhnNumbr.Items.Count > 1) Number2 = ListBox_PhnNumbr.Items[1].ToString(); if (ListBox_PhnNumbr.Items.Count > 2) Number3 = ListBox_PhnNumbr.Items[2].ToString(); if (ListBox_PhnNumbr.Items.Count > 3) Number4 = ListBox_PhnNumbr.Items[3].ToString(); if (ListBox_PhnNumbr.Items.Count > 4) Number5 = ListBox_PhnNumbr.Items[4].ToString(); MessageBox.Show("SOTA Configuration Saved Successfully"); return new SOTA_whitelist_Number(Number1, Number2, Number3, Number4, Number5); }