3

如果我在 Windows 窗体PaintPanel绘制一些水平线。然后我将Graphics对象传递给一个函数以在水平线上绘制其他图形。

现在我必须在 WPF 中绘制相同的水平线并在水平线上绘制其他图形(使用 XBAP 在浏览器中显示 WPF)。我不知道在 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);
    }
}
4

2 回答 2

1

尝试在画布上绘制所有这些。

为此,您可以使用 Canvas.SetTop(object, location) 和 Canvas.SetLeft

于 2013-06-04T13:57:23.373 回答
1

如果您想减轻疼痛,请尝试Visifire

于 2013-06-04T14:21:50.513 回答