如果視窗是canvas就是
Ellipse ellipse = new Ellipse();
ellipse.Width = 50;
ellipse.Height = 100;
ellipse.Stroke = new SolidColorBrush(Colors.Blue);
ellipse.Fill = new SolidColorBrush(Colors.Green);
ellipse.SetValue(Canvas.LeftProperty, 50D);
ellipse.SetValue(Canvas.TopProperty, 100D);
canvas.Children.Add(ellipse);
如果是Grid
這兩句就改成
ellipse.SetValue(Grid.ColumnProperty, 1);
ellipse.SetValue(Grid.RowProperty, 1);
資料都是舉例
如果視窗是canvas就是
Ellipse ellipse = new Ellipse();
ellipse.Width = 50;
ellipse.Height = 100;
ellipse.Stroke = new SolidColorBrush(Colors.Blue);
ellipse.Fill = new SolidColorBrush(Colors.Green);
ellipse.SetValue(Canvas.LeftProperty, 50D);
ellipse.SetValue(Canvas.TopProperty, 100D);
canvas.Children.Add(ellipse);
如果是Grid
ellipse.SetValue(Canvas.LeftProperty, 50D);
ellipse.SetValue(Canvas.TopProperty, 100D);
這兩句就改成
ellipse.SetValue(Grid.ColumnProperty, 1);
ellipse.SetValue(Grid.RowProperty, 1);
資料都是舉例