Pre loader

Sharing ViewModel instance over multiple charts stops updating



I am having a problem with two SciChartSurface’s sharing the same ViewModel instance. I am using the Master-Detail View pattern to provide a list of charts (Collection of SciChart surfaces) with continuously updating data from a device) within a Listbox container on the left-hand side. On the right-hand side I provide the current selected chart with extended size and some extra controls.

The visual appearance of the SciChartSurface (shared across both sides) is defined via data template

    <local:WorkspaceViewModel x:Key="WorkspaceViewModel" />
    <DataTemplate x:Key="ChartDataTemplate">
        <Border MinHeight="200">
            <visuals:SciChartSurface DebugWhyDoesntSciChartRender="True"
                                     SeriesSource="{Binding ., Mode=TwoWay}">
                    <visuals:NumericAxis VisibleRange="0.0, 10.0"
                                         AutoRange="Always" />

                    <visuals:NumericAxis VisibleRange="-1.0, 1.0"
                                         AutoRange="Always" />
                    <visuals:SeriesValueModifier ReceiveHandledEvents="True"></visuals:SeriesValueModifier>

and is used within the ListBox and ContentControl in the following way

<Grid DataContext="{StaticResource WorkspaceViewModel}">
        <ColumnDefinition Width="200*"
                          MaxWidth="700" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="375*" />

    <GroupBox Grid.Column="0">
        <ListBox x:Name="ListBox"
            SelectedItem="{Binding SelectedChart}"
                 ItemsSource="{Binding Charts}"
                 ItemTemplate="{StaticResource ChartDataTemplate}" />
    <GridSplitter Grid.Column="1"
                  ResizeBehavior="PreviousAndNext" />
    <GroupBox Grid.Column="2">
        <ContentControl x:Name="ContentControl"
            Content="{Binding SelectedChart}"
                        ContentTemplate="{StaticResource ChartDataTemplate}" />

The ViewModel (WorkspaceViewModel) contains two properties:

ObservableCollection<ObservableCollection<IChartSeriesViewModel>> Charts
public ObservableCollection<IChartSeriesViewModel> SelectedChart

So far, so good. Once populated with live chart data, the ListBox displays all charts with live updating of the DataSeries. The issue I encounter is that once a chart in the ListBox is selected, the Detail View gets updated and continues displaying live data updates, but the ListBox entry stops updating. Obviously the sharing of the same instance of IChartSeriesViewModel in two different SciChartSurface views (via the ViewModel property SelectedChart) is causing trouble.

What am I missing here? I am currently using SciChart 3.0.

Many thanks,


  • You must to post comments

Hi Silvio,

I wouldn’t recommend using SeriesSource and sharing the source for two charts. Why? Because the IChartSeriesViewModel actually contains a RenderableSeries (a FrameworkElement) and a DataSeries (a plain CLR object). Having these shared on two charts means that one RenderableSeries (FrameworkElement) instance is on two SciChartSurfaces – a big no no in WPF.

You may share DataSeries no problem. You just cannot share RenderableSeries There are some known issues with multi-threading (updating DataSeries on background thread) when DataSeries are shared across charts, but, if you are updating on the UI thread, this will work fine.

What I would suggest is one of the following:

  1. Restructure your application so you do not share IChartSeriesViewModel instances between SciChartSurfaces (you may still share DataSeries)
  2. Restructure your application so you are not using SeriesSource. We provide some alternatives for MVVM binding to DataSeries in this thread.

Finally, an FYI please see this FAQ on Best Practices for MVVM in SciChart. It may be useful!

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies