What does Cannot modify the logical children for this node at this time because a tree walk is in progress mean? What does Cannot modify the logical children for this node at this time because a tree walk is in progress mean? wpf wpf

What does Cannot modify the logical children for this node at this time because a tree walk is in progress mean?


SOLVED!

The problem: I want to update my chart on the GUI every time some data is changed.

 myChart.DataContext = MTFdata;

when i do this i gett the error: Cannot modify the logical children for this node at this time because a tree walk is in progress

How I solved it:

Insted of this:

 <chartingToolkit:LineSeries   DependentValuePath="Key"                                                     IndependentValuePath="Value"                                                     ItemsSource="{Binding}"                                                    IsSelectionEnabled="False"                                                                             >

Use This:

 <chartingToolkit:LineSeries   DependentValuePath="Key"                                                     IndependentValuePath="Value"                                                     ItemsSource="{Binding}"                                                    DataContext="{Binding}"                                                    IsSelectionEnabled="False"                                                                             >

Use both ItemsSource="{Binding}" and DataContext="{Binding}"

Hope this helps!


After playing around more, I think this is a bug in the Silverlight charting toolkit.

The following code causes a reproduceable crash.

int runCount = 0;        private void bindChart(string searchString)        {           List<KeyValuePair<DateTime, int>> dataEmpty = new List<KeyValuePair<DateTime, int>>();            List<KeyValuePair<DateTime, int>> dataFilled = new List<KeyValuePair<DateTime, int>>();            dataFilled.Add(new KeyValuePair<DateTime, int>(DateTime.Today, 1));            if (runCount == 0)            {                Chart1.DataContext= dataEmpty;            }            else            {                Chart1.DataContext = dataFilled;            }            runCount++;        }

XAML:

<charting:Chart Grid.Row="0"    Title="Title"    LegendTitle="Legend" Name="Chart1" Grid.RowSpan="2">            <charting:AreaSeries ItemsSource="{Binding}"                                       DependentValuePath="Value"                                       IndependentValuePath="Key"                                       Background="Red" />        </charting:Chart>

This will fail on the second call to bindChart.


Hej,

I've just had the error, and fixed it as well.The error also accoured when setting the datacontext.

I found that I had a selectionchanged-subscription on the list that was having its datacontext set. In this selectionchanged i was altering another property with notification support, which had a visual element binding on it.

Solved the problem by using the dispatcher for setting the property.

So try look for subscriptions on changes...