Reputation: 831
I've got this function that just draws an ellipse and places it on the given grid
public void drawEllipse(double top, double left, double height, double width, Grid grid)
{
Ellipse ellipse = new Ellipse();
ellipse.Height = height;
ellipse.Width = width;
SolidColorBrush brush = new SolidColorBrush();
brush.Color = Colors.Black;
ellipse.Stroke = brush;
ellipse.Fill = brush;
Canvas.SetTop(ellipse, top);
Canvas.SetLeft(ellipse, left);
grid.Children.Add(ellipse);
}
However, for some reason, it only wants to place the ellipse in the center of the grid, or (given fourth quadrant arguments) the fourth quadrant of the grid.
Am I doing something wrong?
Upvotes: 0
Views: 198
Reputation: 12811
You are adding your ellipse to a Grid
control, but you're setting the Canvas.Top
and Canvas.Left
properties. Without the ellipse actually being on a Canvas
, those two properties don't do anything. Either add a Canvas
and use Canvas.Children.Add
instead of Grid.Children.Add
, or change your Canvas.SetTop
and Canvas.SetLeft
calls with calls to Grid.SetRow
and Grid.SetColumn
.
Upvotes: 1