rolo

rolo

  • NA
  • 1
  • 7.1k

VB.Net & WPF - Point List to WPF Toolkit Graph/Chart

Jan 16 2011 6:15 PM

Can anyone give me an example of how to plot a list of points created from textbox entries on to a WPF Toolkit Graph/Chart that is using a LineSeries?
I have the following Sub run when a user clicks a button:
Note: Home_SF# and Home_SP# are the names of my textboxes.
 

Private Sub Calc()
Dim PntList As List(Of KeyValuePair(Of Integer, Integer))
If Not PntList Is Nothing Then
If Home_SF1.Text = "" Then
Else
If Home_SP1.Text = "" Then
Else
PntList.Add(
New KeyValuePair(Of Integer, Integer)(Home_SF1.Text, Home_SP1.Text))
PC_SF1.Content =
"Math.Round((Home_SP1.Text / Home_SF1.Text), 2)
End If
End If
If Home_SF2.Text = "" Then
Else
If Home_SP2.Text = "" Then
Else
PntList.Add(
New KeyValuePair(Of Integer, Integer)(Home_SF2.Text, Home_SP2.Text))
PC_SF2.Content =
Math.Round((Home_SP2.Text / Home_SF2.Text), 2)
End If
End If
If Home_SF3.Text = "" Then
Else
If Home_SP3.Text = "" Then
Else
PntList.Add(
New KeyValuePair(Of Integer, Integer)(Home_SF3.Text, Home_SP3.Text))
PC_SF3.Content =
Math.Round((Home_SP3.Text / Home_SF3.Text), 2)
End If
End If
If Home_SF4.Text = "" Then
Else
If Home_SP4.Text = "" Then
Else
PntList.Add(
New KeyValuePair(Of Integer, Integer)(Home_SF4.Text, Home_SP4.Text))
PC_SF4.Content =
Math.Round((Home_SP4.Text / Home_SF4.Text), 2)
End If
End If
DirectCast(myChart.Series(0), LineSeries).ItemsSource = PntList
Else
End If
End Sub

Sorry if my code is not the best way to go about this, but my lack of references for what I am trying to do is somewhat hindering, but it does work with the exception of adding my points/KeyValuePair to the chart.
Thanks in advance.