private void PopulateListbox() { // Grab the baseline data. BaselineDataForChart bdfc = new BaselineDataForChart(); // Clear the listbox. lbPlan.Items.Clear(); // Instantiate the idarray. idarray = new int[bdfc.Count()]; // Populate list box. foreach (WeightRecord cr in bdfc) { ListBoxItem lbi = new ListBoxItem(); if (cr.week == 0) { lbi.Content = "Goal weight of " + cr.weight.ToString("0.0") + " reached!"; } else { lbi.Content = "Week " + cr.week.ToString() + " start weight is " + cr.weight.ToString("0.0"); } lbi.FontSize = 28; lbPlan.Items.Add(lbi); idarray[lbPlan.Items.IndexOf(lbi)] = cr.id; } }