0
OxyPlot does not update view when adding Points (Dispatcher)
I'm working on a performance monitor showing plotting some x/y Points as AreaSeries. For presentation I'm updating my view several seconds and adding measuring points. Because of `InvalidOperationException`, I need to add the points inbetween a Dispatcher. I want to see the added points real-time - but the view does not update. There is no issue with the points or anything other, because adding all points before, I get my Plot.
.xaml file
<UserControl x:Class="Gauge_3.PerformanceMonitor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Gauge_3"
xmlns:oxy="http://oxyplot.org/wpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<oxy:PlotView x:Name="fMonitor" Grid.Row="0" HorizontalContentAlignment="Stretch"/>
<oxy:PlotView x:Name="sMonitor" Grid.Row="1"/>
<oxy:PlotView x:Name="nMonitor" Grid.Row="2"/>
</Grid>
</UserControl>
.cs snippet, calling from another class
public void PlotRealTime(double percent)
{
this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
{
DataPoint dPoint = new DataPoint(new DateTime(2017, 01, 01, 14, internalCounter, 00).ToOADate(), percent);
sArea.Points.Add(dPoint);
if (internalCounter == 0)
sMonitor.Model.Series.Add(sArea);
sMonitor.Model.InvalidatePlot(true);
}));
internalCounter++;
}
Customer support service by UserEcho