LineGraph's bound DataSource not updated when not fit to view

Oct 30, 2009 at 11:21 AM


First of all, thanks for the excellent and constantly improving library, I'm using a nightly build (v0.3.4231.0) and ran into the following problem. I have a DataTemplate, where a LineGraph is bound to display some data:

<d3:LineGraph DataSource="{Binding Values}"/>

Normally, the LineGraph is updated when the underlying object changes and the DataTemplate is re-evaluated. But if I move or zoom from the initial view, the LineGraph doesn't update anymore. Other UI elements do show the change, for example I tested with a VerticalLine and it does change correctly all the time:

<d3:VerticalLine Value="{Binding Value}"/>

To correct this, I need to right-click on the view and select 'Fit to View'. It immediately updates to display the correct LineGraph and continues to work until the view is moved or zoomed again.

This error came up within a bigger prototype application and I don't have a repro solution, sorry.

Best regards,

   - Jussi

Oct 30, 2009 at 5:24 PM

Hi Jussi,

Can you please give me a sample of that DataTemplate that contains LineGraph - it may help me to reproduce this error.

Best regards,


Oct 31, 2009 at 3:51 AM

Hi Jussi,

I've created a simple application that has:

ObservableCollection<Point>, that is a container for our data,

in plotter.Loaded I've wrapped this collection into dataSource by calling data.AsDataSource() extension method,

and assigned this to window's DataContext.


In Xaml I have plotter with LineGraph inside, with lineGraph's DataSource property bound to DataContext (by this markup: DataSource="{Binding}").

And all worked as it was supposed to work - when collection changes, chart redraws.

That's why I have a question - maybe you are using underlying data collection that does not support notifications about its changes? If this is so, than behavior you've described is right, as at FitToView command being executed chart refetches its data and redraws itself.

Best regards,


Nov 2, 2009 at 7:42 AM

Hi Mikhail,

Thank you for looking into this. I don't think I was able to describe my situation clearly enough, so I'll try again.

First of all, you're right, the underlying data source doesn't support change notifications. But that should be okay in my case, I don't really need that. Let me elaborate. I have a master list of objects, some of which (when selected) are visualized in a details panel with a LineGraph. Some are visualized with other UI components. There's a DataTemplateSelector for the details panel, which chooses the DataTemplate to use depending on the selected item's type. Here's XAML for the details panel:

<ContentControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="{Binding Path=SelectedItem}" ContentTemplateSelector="{DynamicResource ComparisonsItemDataTemplateSelector}"/>

SelectedItem in the Content parameter is bound to the list's selected item. Below is the DataTemplate with LineGraphs, which is bound implicitly to the selected item whenever they are selected in the list and the DataTemplateSelector is evaluated.

<DataTemplate x:Key="ScalarDistributionDataTemplate">
      <d3:LineGraph Stroke="Blue" DataSource="{Binding Distribution.ControlValues}"/>
      <d3:LineGraph Stroke="Red" DataSource="{Binding Distribution.ComparisonValues}"/>
      <d3:VerticalLine Value="{Binding Value}"/>

ControlValues and ComparisonValues are EnumerableDataSource<Point>s and they are replaced (as are the containing objects) whenever the list selection is changed. As I explained in my previous post, everything works fine as long as the user doesn't zoom or move ChartPlotter's view. That is, selecting an item from the master list results in the ScalarDistributionDataTemplate being chosen and the graph being updated correctly. Only if the view is zoomed or moved by the user, LineGraph updates don't happen (VerticalLine is still updated correctly).

One more thing. I put breakpoints to property getters in Value, ControlValues and ComparisonValues (which are displayed in the ChartPlotter). All getters are called once immediately when a new item is selected in the list. Then, VerticalLine is updated immediately in the view, but ControlValues and ComparisonValues are not updated if the chart is not fitted to view. When the chart is fit to view, ControlValues and ComparisonValues getters are not called again, which means that the new values have been stored by the LineGraphs when the selected item was changed, but it just didn't update the view at that time.

I hope my explanation of the situation is not too cryptic...

    - Jussi

Nov 2, 2009 at 9:03 AM

Hi Jussi,

I have reproduced this bug thanks to your explanations and there is a fix:

paste the following code somewhere in the LineGraph class:


protected override void OnDataSourceChanged(DependencyPropertyChangedEventArgs args)
  filteredPoints = null;

This fix will also be included in the next and following changesets.

Thanks for discovering the bug!

Best regards,



Nov 2, 2009 at 11:11 AM

Excellent, thank you for the fix. Keep up the great work!


    - Jussi