Pre loader

I want to Bind SelectedPointMarkers of DataPointSelectionModifier

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
0

I making MVVM application.

I want to Bind SelectedPointMarkers of DataPointSelectionModifier.
But SelectedPointMarkers is readonly property.

Therefore, I couldn’t bind.

How can I bind it?

Version
5.1.1.11473
  • You must to post comments
0
0

I think our DataPointSelectionModifier example binds to this property – but we bind to an existing collection.

Look here:

WPF Chart Data-Point Selection

and in the code…

    <ListBox ItemsSource="{Binding Source={x:Reference Name=PointMarkersSelectionModifier}, Path=SelectedPointMarkers}">

Best regards
Andrew

  • You must to post comments
0
0

Thank you for your reply.

How to ask questions was not good.

We understand that Bind between controls in View is possible.

I want to Bind to the property of ViewModel, is it possible?

  • Andrew Burnett-Thompson
    No it won’t work as its a readonly property as you said. The best thing you can do is to create an attached behaviour that passes the value to your ViewModel.
  • You must to post comments
0
0

It was possible to solve by inheriting DataPointSelectionModifier and creating your own DependencyProperty for SelectedPointMarkers2.

Thanks a lot.

public class DataPointSelectionModifierExtention : DataPointSelectionModifier
{
    public ObservableCollection<DataPointInfo> SelectedPointMarkers2
    {
        get => (ObservableCollection<DataPointInfo>)GetValue(SelectedPointMakers2Property);
        set => SetValue(SelectedPointMakers2Property, value);
    }
    public static readonly DependencyProperty SelectedPointMakers2Property =
        DependencyProperty.Register(
            nameof(SelectedPointMarkers2),
            typeof(ObservableCollection<DataPointInfo>),
            typeof(DataPointSelectionModifierExtention),
            new PropertyMetadata(new ObservableCollection<DataPointInfo>()));

    public DataPointSelectionModifierExtention()
    {
        base.SelectedPointMarkers.CollectionChanged += SelectedPointMakers_CollectionChanged;
    }

    private void SelectedPointMakers_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
    {
        switch (e.Action)
        {
            case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                foreach (var item in e.NewItems.Cast<DataPointInfo>())
                {
                    this.SelectedPointMarkers2.Add(item);
                }
                break;
            case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
                SelectedPointMarkers2.Clear();
                break;
            case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                foreach (var item in e.OldItems.Cast<DataPointInfo>())
                {
                    this.SelectedPointMarkers2.Remove(item);
                }
                break;
            case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
            case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
            default:
                throw new ApplicationException();
        }
    }
}
  • You must to post comments
Showing 3 results
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