ND's
ND's

Reputation: 2225

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. Then I pass the Graphics object to a function to draw other graphs on horizontal lines.

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). I don't know what to use in WPF to draw a graph dynamically (I have to show graph in a browser).

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);
    }
}

Upvotes: 3

Views: 480

Answers (2)

Xelom
Xelom

Reputation: 1625

If you want to lower your pain try Visifire

Upvotes: 1

kformeck
kformeck

Reputation: 1933

Try drawing all of this on a Canvas.

To do this, you can just use Canvas.SetTop(object, location) and Canvas.SetLeft

Upvotes: 1

Related Questions