gpt4 book ai didi

c# - OxyPlot InvalidatePlot 不刷新数据

转载 作者:行者123 更新时间:2023-11-30 22:06:30 24 4
gpt4 key购买 nike

我正在尝试向 LineSeries 动态添加点,但在使绘图无效后它没有显示。使用直接来自 NuGet 的最新 OxyPlot 版本 2014.1.301.1。如果我将 ItemSource 设置为新列表,它会起作用,但编辑 Items 属性不会执行任何操作。

XAML:

<Window x:Class="SparrowTesting.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sparrow="http://sparrowtoolkit.codeplex.com/wpf"
xmlns:oxy="http://oxyplot.codeplex.com"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<oxy:Plot Title="OxyTest" x:Name="chart">
<oxy:Plot.Series>
<oxy:LineSeries></oxy:LineSeries>
</oxy:Plot.Series>
</oxy:Plot>
<Button Grid.Row="1" x:Name="button1" Click="button1_Click">
<TextBlock>GO</TextBlock>
</Button>
</Grid>
</Window>

代码:

 chart.Series[0].Items.Add(new DataPoint(1, 2));
chart.InvalidatePlot(true);//Does nothing

最佳答案

忽略 Items 属性并仅使用 ItemSource,然后它就可以正常工作了。

chart.Series[0].ItemsSource = new List<DataPoint>();
(chart.Series[0].ItemsSource as List<DataPoint>).Add(new DataPoint())
//Profit

关于c# - OxyPlot InvalidatePlot 不刷新数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23631724/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com