Pre loader

I want to make independent point selections on multiple charts.

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums


Referring to the link above, we have modified the ViewModel side to maintain the selection state of chart points.

It works fine for a single chart, but when I have multiple charts, the selection points are interlocked between charts. I would like them to be independent of each other.

I wasn’t sure if there was a problem with my code or with the DataPointSelectionModifier, so does anyone know?

I have attached a code sample and a GIF of a working image.

※To reproduce this, click the three points in order from the top while holding down the control key on “Chart1” to make the three points selected. The color of the points will change from blue to red.
Next, while holding down the control key in “Chart2,” click on the bottom point. Then, in “Chart2,” four points are selected, even though only one point is pressed in total.

That is all. Best regards.

  • You must to post comments

Hi there,

There’s nothing static in DataPointSelectionModifier or SciChartSurface that would share selected points between chart instances.

You do however declare a DependencyProperty in your custom class like this:

public class DataPointSelectionModifierExtention : DataPointSelectionModifier
    public ObservableCollection<DataPointInfo> SelectedPointMarkers2
        get => (ObservableCollection<DataPointInfo>)GetValue(SelectedPointMakers2Property);
        set => SetValue(SelectedPointMakers2Property, value);
    public static readonly DependencyProperty SelectedPointMakers2Property =
            new PropertyMetadata(new ObservableCollection<DataPointInfo>())); // HERE

This unknowingly creates a single instance of ObservableCollection<DataPointInfo> and assigns it as the default value of DataPointSelectionModifierExtention.SelectedPointMarkers2. So if you are getting points shared between charts this could be the reason.

What I suggest:

  • Never set an instance of a reference type as the default value in a dependency property (see here for more info)
  • Instead, use this.SetCurrentValue(SelectedPointMakers2Property, new ObservableCollection<DataPointInfo>()); to set the value of the dependency property to a new ObservableCollection. The best place to do this would be your DataPointSelectionModifierExtention constructor

Try that. Remove the default value and set it later in the ctor so you have one ObservableCollection instance per DataPointSelectionModifierExtention instance

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