Reputation: 2225
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
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