简体   繁体   English

我可以使用哪个WPF控件来绘制图形?

[英]Which WPF control can I use to draw a graph?

In the Paint event of a Panel I'm drawing some horizontal lines in Windows form. PanelPaint事件中,我在Windows窗体中绘制了一些水平线。 Then I pass the Graphics object to a function to draw other graphs on horizontal lines. 然后我将Graphics对象传递给函数以在水平线上绘制其他图形。

Now I have to draw same horizontal lines in WPF and draw other graphs on horizontal lines (use XBAP to show WPF within the browser). 现在我必须在WPF中绘制相同的水平线并在水平线上绘制其他图形(使用XBAP在浏览器中显示WPF)。 I don't know what to use in WPF to draw a graph dynamically (I have to show graph in a browser). 我不知道在WPF中使用什么来动态绘制图形(我必须在浏览器中显示图形)。

private void pnlViewer_Paint(object sender, PaintEventArgs e)
{
    int cellWidth = (int)((double)1024/ (double)50);
    int cellHeight = (int)((double)768/ (double)50);

    //Draw Horizontal lines.
    int y;
    for (int i = 0; i <= 50; i++)
    {
        y = (i * cellHeight) + cellHeight;
        using (var pen = new Pen(Color.FromArgb(50, 50, 50)))
        {
            e.Graphics.DrawLine(pen, new Point(0, y), new Point(1024, y));
        }
        DrawGraph(e.Graphics);
    }
}

Try drawing all of this on a Canvas. 尝试在画布上绘制所有这些内容。

To do this, you can just use Canvas.SetTop(object, location) and Canvas.SetLeft 为此,您可以使用Canvas.SetTop(对象,位置)和Canvas.SetLeft

如果你想降低你的痛苦,试试Visifire

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM