I have a graph on my WPF to show some plots, the graph is bound to a list called DisplayPoints and when the slider value is changed, one point is moved into DisplayPoints to make it appear on the graph. This is the graphs XAML:
<oxy:Plot Name="Plot" Margin="0,0,10,0" Background="WhiteSmoke">
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding DisplayPoints}" Color="Transparent" MarkerFill="SteelBlue" MarkerType="Circle"/>
</oxy:Plot.Series>
<oxy:Plot.Axes>
<oxy:LinearAxis Position="Left" Minimum="0" Maximum="{Binding BuildPlateSize}"/>
<oxy:LinearAxis Position="Bottom" Minimum="0" Maximum="{Binding BuildPlateSize}"/>
</oxy:Plot.Axes>
</oxy:Plot>
I also have a slider below this graph which controls the % of plots shown on the graph, I am currently handling its events with the ValueChanged event, this is because a requirement is to have the graph update as it is being slide across and not once it has lost focus etc. The XAML for this slider is:
<Slider Name="ProgressSlider" Width="300" Minimum="0" Value="0" Height="30" Foreground="Black" BorderBrush="Black" IsSnapToTickEnabled="True"/>
The maximum is set to however many points the graph has, and creates a tick for each value along the slider. The event handling is as follows:
public async void ProgressSliderEvent(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e)
{
if (e.NewValue > e.OldValue)
{
await this.mainWindow.DisplayNewPoint();
}
else if (e.OldValue > e.NewValue)
{
await this.mainWindow.RemovePoint();
}
this.mainWindow.UpdateGUI(e.NewValue);
}
I am having issues handling the sliding of the slider, when it is slid fast, not all ValueChanges are picked up. For example if I am to control the slider with my arrow keys 100% looks like this:
But if I slide it to 100% normal speed it will only loads a portion of the values because I imagine it moves to fast to fire an event for each value passed over:
My question is how can I handle my slider's events better in a way that will allow me to slide it across and load all values no matter how fast it moves yet updating the graph in real-time?
Any ideas or help will be greatly appreciated, cheers guys.