private void button_removeholding_Click(object sender, RoutedEventArgs e) { string toRemove = listBox_holding.SelectedValue.ToString(); foreach (FScoreHolding fsh in Holdings) { if (fsh.StockTicker.Equals(toRemove)) { Holdings.Remove(fsh); break; } } FScoreHoldingXmlHelper.ToXmlFile(Holdings, _holdingFileName); UpdateHoldingStocks(); }
private void button_addholding_Click(object sender, RoutedEventArgs e) { string addme = textBox_holding.Text; // eventually add stock checker and object filler FScoreHolding hold = new FScoreHolding(); hold.StockName = addme; hold.StockTicker = addme; Holdings.Add(hold); FScoreHoldingXmlHelper.ToXmlFile(Holdings, _holdingFileName); UpdateHoldingStocks(); }
// update the list in the UI by reading the xml file private void UpdateHoldingStocks() { Holdings.Clear(); List <FScoreHolding> holdings = FScoreHoldingXmlHelper.FromXmlFile <List <FScoreHolding> >(_holdingFileName); if (holdings != null) { Holdings = holdings; } // now populate the listbox listBox_holding.Items.Clear(); foreach (FScoreHolding fsh in Holdings) { listBox_holding.Items.Add(fsh.StockTicker); } }