I am trying to bind a XamDataChart to an ObservableCollection so that it gets updated in real time as data is added. Here's the XAML:
<ig:XamDataChart Name="AltitudeDataChart" ><ig:XamDataChart.Axes><ig:CategoryDateTimeXAxis x:Name="altXAxis"VerticalAlignment="Bottom"DateTimeMemberPath="GeoPosition.Timestamp.DateTime" DisplayType="Continuous" ItemsSource="{Binding}" Label="{}"><ig:CategoryDateTimeXAxis.LabelSettings><ig:AxisLabelSettings Location="OutsideBottom" Extent="25"/></ig:CategoryDateTimeXAxis.LabelSettings></ig:CategoryDateTimeXAxis><ig:NumericYAxis x:Name="altYAxis" ><ig:NumericYAxis.LabelSettings ><ig:AxisLabelSettings Location="OutsideLeft" FontSize="18" Foreground="{StaticResource PhoneForegroundBrush}"/></ig:NumericYAxis.LabelSettings></ig:NumericYAxis></ig:XamDataChart.Axes><ig:XamDataChart.Series><ig:AreaSeries x:Name="AltitudeAreaSeries" ValueMemberPath="GeoPosition.Location.Altitude" ItemsSource="{Binding}" TrendLineType="CubicFit" TrendLineBrush="Yellow" TrendLineDashArray="5" TrendLineThickness="3"XAxis="{Binding ElementName=altXAxis}" YAxis="{Binding ElementName=altYAxis}"><ig:AreaSeries.Brush><SolidColorBrush Color="Blue"></SolidColorBrush></ig:AreaSeries.Brush></ig:AreaSeries></ig:XamDataChart.Series></ig:XamDataChart>
In the code behind, I have the following:
this.AltitudeDataChart.DataContext = activityViewModel.CurrentActivity.Data;
where Data is an object of the following type: ObservableCollection<ActivityData> and ActivityData has the following property:
public GeoPosition<GeoCoordinate> GeoPosition { get; set; } ... parts omitted for brevity.
Suffice it to say that if I reference GeoPosition.Location.Altitude and GeoPosition.Timestamp.DateTime, the binding should work. And it does work fine if I don't go to the control which is hosted in a Pivot control. But as soon as an update is made and I'm on the chart, I get the following exception:
{System.ArgumentNullException: Value cannot be null. Parameter name: collection at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection) at Infragistics.FastItemsSource.dataSourceAdd(Int32 position, IList newItems) at Infragistics.FastItemsSource.<Attach>b__0(FastItemsSource fastItemsSource, Object sender, NotifyCollectionChangedEventArgs e) at Infragistics.ItemSourceEventProxy.collectionChanged(Object sender, NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item) at System.Collections.ObjectModel.Collection`1.Add(T item) at ActivityTracker.Code.Activity.<AddData>d__1.MoveNext()}
Does anyone have any ideas here?
Hello,
Thank you for your post. I have been looking into it, but it seems like that I am missing something in your scenario, so if this is still an issue for you, could you please send an isolated sample project, where the issue is reproduced, so I can investigate it further for you.
Looking forward for your reply.
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.