Hi,
I am developing an MVVM WPF application and need to access the SelectedPointMarkers property of DataPointSelectionModifier from the ViewModel.
From looking at the DataPointSelectionModifier documentation (https://www.scichart.com/documentation/win/current/webframe.html#DataPoint%20Selection.html) I can see how you can get the X and Y coordinate values of a selected point in a view, by binding the PointMarkersSelectionModifier to a listbox.
However this doesn’t really help me, I need to get the coordinates of the SelectedPointMarker into a property inside the ViewModel that can be accessed, rather than just binding to a listbox in the view itself.
I’ve also looked at this similar post: (https://www.scichart.com/questions/wpf/i-want-to-bind-selectedpointmarkers-of-datapointselectionmodifier), but I had no luck getting Kenishis solution to work in my case.
How can i do this?
Thanks.
- Sean Connell asked 3 years ago
- You must login to post comments
Hi Sean,
It’s possible to solve by inheriting the DataPointSelectionModifier and creating your own dependency property for SelectedPointMarkers
public class DataPointSelectionModifierExtended : DataPointSelectionModifier
{
public static readonly DependencyProperty AllSelectedPointMarkersProperty = DependencyProperty.Register
(nameof(AllSelectedPointMarkers),
typeof(ObservableCollection<DataPointInfo>),
typeof(DataPointSelectionModifierExtended),
new PropertyMetadata(new ObservableCollection<DataPointInfo>()));
public ObservableCollection<DataPointInfo> AllSelectedPointMarkers
{
get => (ObservableCollection<DataPointInfo>)GetValue(AllSelectedPointMarkersProperty);
set => SetValue(AllSelectedPointMarkersProperty, value);
}
public DataPointSelectionModifierExtended()
{
SelectedPointMarkers.CollectionChanged += OnCollectionChanged;
}
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
e.NewItems.Cast<DataPointInfo>().ForEachDo(p => AllSelectedPointMarkers.Add(p));
break;
case NotifyCollectionChangedAction.Reset:
AllSelectedPointMarkers.Clear();
break;
case NotifyCollectionChangedAction.Remove:
e.OldItems.Cast<DataPointInfo>().ForEachDo(p => AllSelectedPointMarkers.Remove(p));
break;
case NotifyCollectionChangedAction.Replace:
case NotifyCollectionChangedAction.Move:
default: throw new NotImplementedException();
}
}
}
Best regards,
Dmytro
- Dmytro Herasymenko answered 3 years ago
- You must login to post comments
Please login first to submit.