Project - WPF, C#, IDE - Visual Studio. I want bind value traking on my PlotView. My code XAML:
<Border CornerRadius="6" BorderBrush="Gray" BorderThickness="4" Grid.Column="0" Grid.ColumnSpan="2">
<oxy:PlotView Background="White" Model="{Binding GraphicModel.Model}" >
</oxy:PlotView>
</Border>
<TextBlock Text="{Binding CurrentTrackerValue}" Grid.Column="0" Grid.Row="1"/>
I know, what PlotView.Model have event TrackerChange. How using this event? P.S.: I use pattern MVVM, so i want using command instead event. Thank!
If I understand your requirement correctly, you want to update a TextBlock each time the Tracker is updated. I believe you were right on track with the TrackerChanged event. You could do the following in your ViewModel, where you are creating the PlotModel instance, which would be bound to the OxyPlot Graph
PlotModelName.TrackerChanged += (sender, eventArgs)=>
{
CurrentTrackerValue = eventArgs.HitResult != null ? eventArgs.HitResult.Text : CurrentTrackerValue;
NotifyPropertyChanged(nameof(CurrentTrackerValue));
};
Where CurrentTrackerValue is defined as
public string CurrentTrackerValue { get; set; }
This would ensure the CurrentTrackerValue property is updated each time Tracker is changed via the TrackerChangedEvent