This is a migrated thread and some comments may be shown as answers.

Binding ItemsSource to LineSeries

2 Answers 410 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
kl
Top achievements
Rank 1
kl asked on 06 Nov 2012, 03:59 AM
I'm having difficulty to display the data on the chart where the data are changed dynamically.
The graph would not populate the data according to the changes made.
Below is the snippet of the code, kindly guide if i did anything wrong.

p/s: The GetData will get the changes of data to be plot on the graph

XAML:
<chartView:LineSeries Stroke="Red" StrokeThickness="2" ItemsSource="{Binding ListValue}" ValueBinding="Value" CategoryBinding="Category">

ViewModel.cs
private List<SampleClass> tempList;
public List<SampleClass> ListValue
{
     :
     :
}
public void GetData(string tempValue)
{
       SampleClass item = new SampleClass ();
       item.Value= tempValue;
       item.Category = m_counter++;
       tempList.Add(item);
 
       ListValue= tempList;
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Petar Kirov
Telerik team
answered on 08 Nov 2012, 05:38 PM
Hi,

The problem is that the List<> class does not notify the chart that its data has changed. Changing the ItemsSource from List<> to ObservableCollection<> should solve the problem.
 
Regards,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
kl
Top achievements
Rank 1
answered on 12 Nov 2012, 02:30 AM
thank you. it works fine now.
Tags
ChartView
Asked by
kl
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
kl
Top achievements
Rank 1
Share this question
or