簡體   English   中英

OxyPlot InvalidatePlot不刷新數據

[英]OxyPlot InvalidatePlot not refreshing data

我正在嘗試向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 ,然后將其像ItemSource一樣工作。

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

我無法工作chart.InvalidatePlot(true); 但是chart.Series.Clear(); 運作良好。 我會嘗試將其放置在新數據點之前,如下所示:

chart.Series.Clear(); 
chart.Series[0].Items.Add(new DataPoint(1, 2));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM