我有一组点(代表一个sin图)我如何在wpf中绘制图形?

时间:2014-11-30 09:37:24

标签: c# wpf xaml

我有一组点(代表一张罪孽图)我如何绘制图形?

c#c​​ode:

string[] lines = System.IO.File.ReadAllLines("AnaloguData.txt");
PointCollection myPointCollection = new PointCollection();

for (int i = 0; i < lines.Length; i++)
{
    string[] words = lines[i].Split('\t');
    myPointCollection.Add(new Point(Convert.ToDouble(words[0]), Convert.ToDouble(words[1])));
}
curve.Points = myPointCollection; 

xaml代码:

<Grid>
    <Button Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="61,294,0,0" Click="Button_Click"/>
    <Canvas HorizontalAlignment="Left" Height="477" VerticalAlignment="Top" Width="538" Margin="158,294,0,0">
        <Polyline Name="curve" />
    </Canvas>
</Grid>

我不明白为什么这段代码不起作用。 Sombody有更好的主意吗?

0 个答案:

没有答案