【问题标题】:Which WPF control can I use to draw a graph?我可以使用哪个 WPF 控件来绘制图形?
【发布时间】:2013-06-04 13:39:30
【问题描述】:

PanelPaint 事件中,我正在Windows 窗体中绘制一些水平线。然后我将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);
    }
}

【问题讨论】:

标签: c# wpf wpf-controls


【解决方案1】:

尝试在 Canvas 上绘制所有这些内容。

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

【讨论】:

    【解决方案2】:

    如果你想减轻疼痛,试试Visifire

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-05
      • 1970-01-01
      相关资源
      最近更新 更多