C# 添加点时,OxyPlot不更新视图(调度程序)
我正在制作一个性能监视器,显示将一些x/y点绘制为面积序列。对于演示,我将在几秒钟内更新视图并添加测量点。由于C# 添加点时,OxyPlot不更新视图(调度程序),c#,.net,wpf,xaml,oxyplot,C#,.net,Wpf,Xaml,Oxyplot,我正在制作一个性能监视器,显示将一些x/y点绘制为面积序列。对于演示,我将在几秒钟内更新视图并添加测量点。由于InvalidOperationException,我需要在调度程序之间添加点。我希望实时查看添加的点,但视图不会更新。点或其他任何东西都并没有问题,因为在添加所有点之前,我得到了我的图 .xaml文件 <UserControl x:Class="Gauge_3.PerformanceMonitor" xmlns="http://schemas.micro
InvalidOperationException
,我需要在调度程序之间添加点。我希望实时查看添加的点,但视图不会更新。点或其他任何东西都并没有问题,因为在添加所有点之前,我得到了我的图
.xaml文件
<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>
也许可以提供更多关于
sArea
是什么以及如何初始化的上下文。也许可以提供更多关于sArea
是什么以及如何初始化的上下文。
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++;
}