Pre loader

Tag: point selection

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

0 votes
11k views

Hello,

Is there a mechanism for binding, in a two way fashion, the collection of Selected points when using the IPointmetadata mechnism?

Basically, I have a view which contains a table (DevExpress Datagrid) and a SciChart plot, where all of the rows are plotted on a line series. When the user highlights a row or rows in the table, the appropriate points should be selected on the graph. Also, if the user selects the points on the graph, the rows should be selected in the table. Ideally, I would like to bind each view’s SelectedRows (or SelectedPoints) to a common ObservableCollection.

The trouble I am seeing is that the two views use different paradigms to represent Selected-ness. The point is only selectable if it is given an object that implements IPointMetadata, and its selection state is represented by the BizObjectViewModel’s IsSelected property. The selection state in the table is represented by its presence in the SelectedRows collection.

No opinions as to which is better, I am simply trying to get the two to work together nicely. OnCollectionChanged of the bound SelectedRows is a great place for me to set/unset IsSelected for the affected object, and the chart reacts:

switch (e.Action)
        {
            case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                foreach (var p in e.NewItems.Cast<SolverDetailRow>())
                {
                    p.IsSelected = true;
                }
                break;
            case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                foreach (var p in e.OldItems.Cast<SolverDetailRow>())
                {
                    p.IsSelected = false;
                }
                break;
            case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
                break;
            case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
                break;
            case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
                foreach (var row in SolverRows)
                {
                    foreach (var detRow in row.Observations)
                    {
                        detRow.IsSelected = false;
                    }
                }
                break;
            default:
                break;
        }

However, I can’t find the best place to update the collection when the chart updates the IsSelected property itself. The BizObjectViewModel won’t (and shouldn’t) know about the collection he is in. Right now I am using a Messenger model from DevExpress to notify anyone who cares that the IsSelected property has changed:

private bool _isSelected;
    public virtual bool IsSelected
    {
        get { return _isSelected; }
        set
        {
            if (value != _isSelected)
            {
                _isSelected = value;
                RaisePropertyChanged("IsSelected");
                Messenger.Default.Send(new PointSelectionChangedMessage() { Object = this });
                Messenger.Default.Send(new ChartRefreshRequestedMessage());
            }
            _isSelected = value;
        }
    }

This at least decouples the view model from knowing about the collection, but it kind of muddies the Viewmodel with piping that seems superfluous. It would be nice if I could bind the DataPointSelectionModifier’s SelectedPoints to the same collection that the table is bound to, but it appears that this is Readonly.

Am I missing something? I suppose I can extend the DataPointSelectionModifier to provide something, but I am hoping I am overlooking a feature…

Thanks for your time,
Mike.

Showing 1 result

Try SciChart Today

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

Start TrialCase Studies