private void addValueBtn_Click(object sender, RoutedEventArgs e) { string name = addValueNameTextBox.Text.Trim(); string valueAsString = addValueValueTextBox.Text.Trim(); double valueAsDouble = Convert.ToDouble(valueAsString); NameValuePair nvp = new NameValuePair(name, valueAsDouble); dataPoints.Add(nvp); addValueNameTextBox.Text = ""; addValueValueTextBox.Text = ""; }