Ellipse ellipse = new Ellipse(); ellipse.Width = 100; ellipse.Height = 50; ellipse.Fill = new SolidColorBrush(Colors.Blue); ellipse.Stroke = new SolidColorBrush(Colors.Black); ellipse.StrokeThickness = 2; canvas.Children.Add(ellipse);
Ellipse ellipse = new Ellipse(); ellipse.Width = 50; ellipse.Height = 50; ellipse.Fill = new LinearGradientBrush(Colors.Red, Colors.Yellow, 45); ellipse.Stroke = new SolidColorBrush(Colors.Blue); ellipse.StrokeThickness = 3; Grid.SetColumn(ellipse, 1); Grid.SetRow(ellipse, 2); grid.Children.Add(ellipse);This example creates an Ellipse object with a width and height of 50, fills it with a gradient brush that goes from red to yellow at a 45 degree angle, and adds a blue border with a thickness of 3 to the shape. It is then added to a Grid object named "grid" at column 1 and row 2. The System.Windows.Shapes Ellipse class is part of the PresentationFramework library, which is included in the .NET Framework and .NET Core.