I have a RadCartesianChart defined in XAML with multiple series. Each series has the ItemsSource, HorizontalAxis, VerticalAxis and Visibility bound to MVVM model properties. The ChartView itself has the DataContext bound inherently from the DataContext of my chartviewer usercontrol's DataContext.
When my control is first displayed, everything works as expected, the chart is displayed correctly and I can switch through the different series with different data and different label formats.
The chartviewer control is part of a ContentControl which picks the relevant View from the assigned DataContext type. This is switched depending on user input.
Firstly, if I navigate away from the chartviewer control I have to use the following code to prevent a "Cannot modify the logical children for this node at this time because a tree walk is in progress" exception from the ChartView:-
private void ChartViewer_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue == null)
{
chartCart.DataContext = null;
chartCart.UpdateLayout();
}
}
Secondly if I then go back to the ChartViewer reusing he same MVVM model that was previously used, the ChartView now show "HorizontalAxis not set" and "VerticalAxis not set". It does not matter what I change on the model, I cannot get the chart to show anything else. When using Visual Studio to look at the ChartView, the DataContext binding is valid, the series are all there, and all of the series have correct bindings to the model properties and seem to be correct. I noticed that the axes get their Chart property set when assigned to the series, so I have tried rebuilding the axes in the same way I do when the chart is working (first view).
I have also tried binding the DataContext of the ChartView to a different DependencyProperty which allows me to get away from the exception (noted above), but still the same problem. I have tried stepping through the Visual Tree and rebuilding all of the bindings to ensure they are all active, but this has no effect.
What would cause the EmptyContent message to show when there are series available, each with axes set and are visible, and have point data?