tags:

views:

55

answers:

0

ERROR: "Cannot modify the logical children for this node at this time because a tree walk is in progress." I call the Chart.Load() sub on the Load of my main form. I know that this has been asked before but I cannot for the life of me get this to work. I need the chart series to update if the underlying data changes, if there is another way to get this to work besides the class and INotifiyPropertyChanged then I'm open to that too.

This link tells you to set the ItemsSource instead of the DataContext but that is what I'm already doing.

Thank you for any input.

                    <DVC:Chart Name="mcChart" Width="Auto" Height="250" Background="Transparent" BorderBrush="Transparent" >
                        <DVC:Chart.Series>
                            <DVC:LineSeries Title=" Budget" IndependentValueBinding="{Binding Path=Month}" DependentValueBinding="{Binding Path=Amt}" />
                            <DVC:LineSeries Title=" Actual" IndependentValueBinding="{Binding Path=Month}" DependentValueBinding="{Binding Path=Amt}" ItemsSource="{Binding Path=ActualSeries}" />
                            <DVC:LineSeries Title=" Projection" IndependentValueBinding="{Binding Path=Month}" DependentValueBinding="{Binding Path=Amt}" />
                        </DVC:Chart.Series>
                    </DVC:Chart>


Public Class Chart
Implements INotifyPropertyChanged

Public Sub New()
    _seriesExpend = New List(Of ChartDataPoint)
End Sub

Private _seriesExpend As List(Of ChartDataPoint)
Public Property ActualSeries() As List(Of ChartDataPoint)
    Get
        Return _seriesExpend
    End Get
    Set(ByVal value As List(Of ChartDataPoint))
        _seriesExpend = value
        OnPropertyChanged("ActualSeries")
    End Set
End Property

Public Sub Load()
    ' Build charts
    For Each dr As DataRow In BudgetData().Tables("ExpenditureGraph").Rows()
        _seriesExpend.Add(New ChartDataPoint(dr.Item(0).ToString, CDbl(dr.Item(1))))
    Next
End Sub

Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged


Protected Sub OnPropertyChanged(ByVal propertyName As String)
    RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
End Sub

End Class