1

Code Behind - I have an Observable Collection of Points which holds data to plot to the graph. This data is read from an external source and will have anything from 20k-80k thousands values in each of these lists.

ObservableCollection<System.Windows.Point> listChannelData =new ObservableCollection <System.Windows.Point>();
ObservableCollection<System.Windows.Point> listActiveBaseline =new ObservableCollection <System.Windows.Point>();

Once these lists are populated, I then set the series ItemSource to these lists like so:

seriesChannelData.ItemsSource = listChannelData;
seriesActiveBaseline.ItemsSource = listActiveBaseline;

XAML - Not sure if the XAML is correct as just started learning, I also don't know if it's better to bind to the Observable Collection in the code or in the XAML.

<DVC:LineSeries Name="seriesChannelData" DependentValuePath="Y" IndependentValuePath="X" ItemsSource="{Binding seriesChannelData}" IsSelectionEnabled="True"/>
<DVC:LineSeries Name="seriesActiveBaseline" DependentValuePath="Y" IndependentValuePath="X" ItemsSource="{Binding}" IsSelectionEnabled="True" />

When I try to run this program it seems to take a long time to populate the lists and nothing charts, so it seems my data binding is wrong. Another thing I would like to find out is if I am wrong in setting the series item source to the lists after they have been populated.

ouflak
  • 2,458
  • 10
  • 44
  • 49
  • 1
    I was researched about it many times but always the code was the best solution. It is really painful though. –  Aug 12 '20 at 04:17
  • Not sure what your exact question is, but binding to fields won't work. They need to be properties. – Clemens Aug 12 '20 at 06:44
  • @Clemens Hi Clemens, I have updated the question to give more details, any help would be appreciated. – Greg Harrison Aug 12 '20 at 11:00

1 Answers1

1
<DVC:Chart Name="seriesChannelData" VerticalAlignment="Top" Height="200"
DataContext="{Binding seriesChannelData}" IsTabStop="True" Background="White">
    <DVC:LineSeries DependentValuePath="Y" IndependentValuePath="X"
ItemsSource="{Binding}">
    </DVC:LineSeries>
</DVC:Chart>

In the DataContext, you will bind the observable collection Name and, in the DependentValuePath and IndependentValuePath, you bind the members of the observable collection.

ouflak
  • 2,458
  • 10
  • 44
  • 49
Kiran
  • 11
  • 2